diff --git a/AK/HashFunctions.h b/AK/HashFunctions.h index ee09fb0cf3d..cbbd97942d1 100644 --- a/AK/HashFunctions.h +++ b/AK/HashFunctions.h @@ -17,3 +17,10 @@ inline unsigned pair_int_hash(u32 key1, u32 key2) { return int_hash((int_hash(key1) * 209) ^ (int_hash(key2 * 413))); } + +inline unsigned u64_hash(u64 key) +{ + u32 first = key & 0xFFFFFFFF; + u32 last = key >> 32; + return pair_int_hash(first, last); +} diff --git a/AK/Traits.h b/AK/Traits.h index f268e669403..c071d5f418e 100644 --- a/AK/Traits.h +++ b/AK/Traits.h @@ -37,6 +37,13 @@ struct Traits : public GenericTraits { static void dump(u16 u) { kprintf("%u", u); } }; +template<> +struct Traits : public GenericTraits { + static constexpr bool is_trivial() { return true; } + static unsigned hash(u64 u) { return u64_hash(u); } + static void dump(u64 u) { kprintf("%u", (unsigned)u); } // FIXME: Implement unsigned long long printf specifier, instead of this sadness :( +}; + template<> struct Traits : public GenericTraits { static constexpr bool is_trivial() { return true; }