clj_hash_collision
Hash collision handling for data structures.
Implements utility functions for dealing with the collision of hashes in data structures such as Clojure maps and sets.Summary
Types
Functions
-
create_entry(Map, Hash, Key, Value)
Create a new entry.
-
equiv(MappingX, MappingY)
Checks if the two mappings are equivalent.
-
get_entry(Map, Hash, Key)
Gets the entry for
Key
inMap
. -
without_entry(Mapping, Hash, Key)
Removes the entry for
Key
.
Types
entry()
-type entry() :: {any(), any()} | [{any(), any()}].
mapping()
-type mapping() :: #{integer() => entry()}.
Functions
create_entry(Map, Hash, Key, Value)
-spec create_entry(mapping(), integer(), any(), any()) ->
{0 | 1, entry()}.
Create a new entry.
Returns a tuple with two elements. The first is either0
(the
value for the provided key already existed) or 1
(a new value was
added to the entry). The second is the created entry.
equiv(MappingX, MappingY)
-spec equiv(mapping(), mapping()) -> boolean().
Checks if the two mappings are equivalent.
get_entry(Map, Hash, Key)
-spec get_entry(mapping(), integer(), any()) ->
undefined | {any(), any()}.
Gets the entry for Key
in Map
.
undefined
when the entry is not found.
without_entry(Mapping, Hash, Key)
-spec without_entry(mapping(), integer(), any()) -> {- 1 | 0, mapping()}.
Removes the entry for Key
.
-1
(the
Key
was removed) or 0
(the Key
was not found). The second is
the updated mapping.