aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/hashlib.h
diff options
context:
space:
mode:
authorPeter Crozier <peter@crozier.com>2020-06-03 17:19:28 +0100
committerGitHub <noreply@github.com>2020-06-03 17:19:28 +0100
commit0d3f7ea011288e1a1fadd4ae27f1e8a57d729053 (patch)
tree07bde0d9f492233728070234aed2abd45fbd464d /kernel/hashlib.h
parent17f050d3c6b8934141c42f96a3418de67a687b2c (diff)
parent46ed0db2ec883a4ce330c81f321511e36e35c0b3 (diff)
downloadyosys-0d3f7ea011288e1a1fadd4ae27f1e8a57d729053.tar.gz
yosys-0d3f7ea011288e1a1fadd4ae27f1e8a57d729053.tar.bz2
yosys-0d3f7ea011288e1a1fadd4ae27f1e8a57d729053.zip
Merge branch 'master' into struct
Diffstat (limited to 'kernel/hashlib.h')
-rw-r--r--kernel/hashlib.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/kernel/hashlib.h b/kernel/hashlib.h
index 592d6e577..5c87b55f5 100644
--- a/kernel/hashlib.h
+++ b/kernel/hashlib.h
@@ -207,6 +207,7 @@ class dict
entry_t() { }
entry_t(const std::pair<K, T> &udata, int next) : udata(udata), next(next) { }
entry_t(std::pair<K, T> &&udata, int next) : udata(std::move(udata)), next(next) { }
+ bool operator<(const entry_t &other) const { return udata.first < other.udata.first; }
};
std::vector<int> hashtable;
@@ -615,6 +616,15 @@ public:
return !operator==(other);
}
+ unsigned int hash() const {
+ unsigned int h = mkhash_init;
+ for (auto &entry : entries) {
+ h ^= hash_ops<K>::hash(entry.udata.first);
+ h ^= hash_ops<T>::hash(entry.udata.second);
+ }
+ return h;
+ }
+
void reserve(size_t n) { entries.reserve(n); }
size_t size() const { return entries.size(); }
bool empty() const { return entries.empty(); }