From cfe0817697c9e7a656fd3a64e3a9014fa86e78d0 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Mon, 29 Dec 2014 02:01:42 +0100 Subject: Converting "share" to dict<> and pool<> complete --- kernel/hashlib.h | 11 +++++++++++ kernel/rtlil.h | 11 +++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) (limited to 'kernel') diff --git a/kernel/hashlib.h b/kernel/hashlib.h index 021cc66ee..4e8c00026 100644 --- a/kernel/hashlib.h +++ b/kernel/hashlib.h @@ -76,6 +76,17 @@ template<> struct hash_ops { } }; +template struct hash_ops> { + bool cmp(std::pair a, std::pair b) const { + return a == b; + } + unsigned int hash(std::pair a) const { + hash_ops

p_ops; + hash_ops q_ops; + return mkhash(p_ops.hash(a.first), q_ops.hash(a.second)); + } +}; + struct hash_cstr_ops { bool cmp(const char *a, const char *b) const { for (int i = 0; a[i] || b[i]; i++) diff --git a/kernel/rtlil.h b/kernel/rtlil.h index 5bca060f4..25477d02e 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -219,8 +219,8 @@ namespace RTLIL return index_; } - // The following is a helper key_compare class. Instead of for example pool - // use pool> if the order of cells in the + // The following is a helper key_compare class. Instead of for example std::set + // use std::set> if the order of cells in the // set has an influence on the algorithm. template struct compare_ptr_by_name { @@ -450,6 +450,13 @@ struct RTLIL::Const std::string decode_string() const; inline int size() const { return bits.size(); } + + inline unsigned int hash() const { + unsigned int h = 5381; + for (auto b : bits) + mkhash(h, b); + return h; + } }; struct RTLIL::SigChunk -- cgit v1.2.3