HashMap requires you to define your own Traits class. Derive your Traits class from
BaseHashMapTraits to reduce the amount of boilerplate code. Your Traits class must define the following members:
(Required) The type used to locate existing items in the hash map.
(Required) The type that gets stored in the hash map itself.
static u32 hash(const Key&)
(Optional) Compute a 32-bit hash value for the key. If you don't define a custom
hashfunction here, the default implementation calls the key's
appendTomember function with a
Hasherobject (an object that helps implement MurmurHash3).
static void construct(Item*, const Key&)
(Optional) Constructs an
Itemin-place. If you don't define
construct, the default implementation tries to pass
Item's constructor (using SFINAE); if no such constructor exists, it calls
Item's default constructor. In all cases, if
Keyis ignored when constructing the
Item, it's the caller's responsibility to ensure that the hash table is left in a consistent state after inserting a new item.
static ComparandType comparand(const Item&)
(Optional) Converts an
Itemto another type, of your choosing, that will be passed as the first argument to
equal. If you don't define
comparandin your traits class, it will inherit a default implementation from
BaseHashMapTraitsthat returns a const reference to the
static ComparandType comparand(const Item&, const Context&)
(Optional) A type to help implement
comparand. If you don't define this type in your traits class, it will inherit an empty struct from
static bool equal(const ComparandType&, const Key&)
trueif the comparand type matches
ComparandTypecan be any type of your choosing. By default, it's
Item, but if you want to make it a different type, implement the
comparandfunction in your Traits class.