diff options
Diffstat (limited to 'kernel/hashlib.h')
-rw-r--r-- | kernel/hashlib.h | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/kernel/hashlib.h b/kernel/hashlib.h index 0b6e94a32..3164282f2 100644 --- a/kernel/hashlib.h +++ b/kernel/hashlib.h @@ -62,7 +62,8 @@ template<> struct hash_ops<int> { bool cmp(T a, T b) const { return a == b; } - unsigned int hash(unsigned int a) const { + template<typename T> + unsigned int hash(T a) const { return a; } }; @@ -90,6 +91,19 @@ template<typename P, typename Q> struct hash_ops<std::pair<P, Q>> { } }; +template<typename T> struct hash_ops<std::vector<T>> { + bool cmp(std::vector<T> a, std::vector<T> b) const { + return a == b; + } + unsigned int hash(std::vector<T> a) const { + hash_ops<T> t_ops; + unsigned int h = mkhash_init; + for (auto k : a) + h = mkhash(h, t_ops.hash(k)); + return h; + } +}; + struct hash_cstr_ops { bool cmp(const char *a, const char *b) const { for (int i = 0; a[i] || b[i]; i++) |