mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-25 10:48:41 +00:00
AK: Add a u64 Trait type
This allows u64s to be used in HashMaps.
This commit is contained in:
committed by
Andreas Kling
parent
9e22b83343
commit
d5fea1b235
@@ -17,3 +17,10 @@ inline unsigned pair_int_hash(u32 key1, u32 key2)
|
|||||||
{
|
{
|
||||||
return int_hash((int_hash(key1) * 209) ^ (int_hash(key2 * 413)));
|
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);
|
||||||
|
}
|
||||||
|
|||||||
@@ -37,6 +37,13 @@ struct Traits<u16> : public GenericTraits<u16> {
|
|||||||
static void dump(u16 u) { kprintf("%u", u); }
|
static void dump(u16 u) { kprintf("%u", u); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct Traits<u64> : public GenericTraits<u64> {
|
||||||
|
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<>
|
template<>
|
||||||
struct Traits<char> : public GenericTraits<char> {
|
struct Traits<char> : public GenericTraits<char> {
|
||||||
static constexpr bool is_trivial() { return true; }
|
static constexpr bool is_trivial() { return true; }
|
||||||
|
|||||||
Reference in New Issue
Block a user