diff options
author | Clifford Wolf <clifford@clifford.at> | 2015-12-02 20:41:57 +0100 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2015-12-02 20:41:57 +0100 |
commit | 33a5b28e2512a17667bb1a1cab9065f723a86041 (patch) | |
tree | e20ec6994b5e35dc1bf8b264b55834e20b25d2e8 /kernel | |
parent | 276101f032126d35770001f99135449d96b145e7 (diff) | |
download | yosys-33a5b28e2512a17667bb1a1cab9065f723a86041.tar.gz yosys-33a5b28e2512a17667bb1a1cab9065f723a86041.tar.bz2 yosys-33a5b28e2512a17667bb1a1cab9065f723a86041.zip |
Added default values for hashlib at() methods
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/hashlib.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/kernel/hashlib.h b/kernel/hashlib.h index 413e77d31..f015bf4dd 100644 --- a/kernel/hashlib.h +++ b/kernel/hashlib.h @@ -506,6 +506,15 @@ public: return entries[i].udata.second; } + T at(const K &key, const T &defval) const + { + int hash = do_hash(key); + int i = do_lookup(key, hash); + if (i < 0) + return defval; + return entries[i].udata.second; + } + T& operator[](const K &key) { int hash = do_hash(key); @@ -896,6 +905,15 @@ public: return i + offset; } + int at(const K &key, int defval) const + { + int hash = database.do_hash(key); + int i = database.do_lookup(key, hash); + if (i < 0) + return defval; + return i + offset; + } + int count(const K &key) const { int hash = database.do_hash(key); |