The type of the values in the hashmap.
Private
#dynamic_Whether or not to use dynamic rehashing.
Private
#hash_The hash function used
User can specify their own, else defaults to _default_hash_function
The hash digest returned by this function is combined with the number of buckets to get the corresponding bucket index for the entry
Private
#hashing_The hashing method to use.
Private
#max_Maximum load factor for dynamic rehashing.
This value is compared with the new load factor after insert/delete operations to determine whether or not to decrease the # of buckets.
Private
#min_Minimum load factor for dynamic rehashing.
This value is compared with the new load factor after insert/delete operations to determine whether or not to increase the # of buckets.
Private
#multiplication_Multiplication factor for hashing by multiplication (if used.)
Private
#stop_When this is true
, insert
and delete
operations will not check for dynamic rehashing.
This is done to prevent a rehash causing another rehash.
The buckets of the hashmap
This is an array of LinkedLists of entries which represented as a tuples of [string, T]
When an entry is inserted, it will become the head of the corresponding LL
When all entries in an LL bucket are removed, the corresponding entry in the array becomes null
; see delete
The number of entries present in the hashmap
Used to calculate load factor
The keys used in the hashmap
Number of times the hashmap was dynamically rehashed (i.e. the number of buckets changed.)
Computed property for the load factor of the hashmap.
Target value for optimal performance is around 0.60 - 0.75
The load factor
a tuple [min, max]
of two integers, representing the inclusive range of allowed number of elements/entries before dynamic rehashing.
If an insertion or deletion operation would cause the number of elements to fall outside of this range, the number of buckets will be adjusted before the insertion/deletion.
null
if dynamic rehashing is not enabled.
Private
_default_Private
_dynamic_Rehashes the hash table if the load factor falls outside the min/max bounds.
true
if rehashed, false
otherwise
When dynamic hashing is not enabled.
Private
_get_Private
Passes hash digest of key through modulo operation to get bucket index.
The index of the corresponding bucket in this.buckets
The key
Private
_hash_Private
_hash_Resizes the number of buckets of the hashmap and rehashes pre-existing elements to the new buckets.
The desired new value for the parameter.
Whether to rehash based on load factor or number of buckets.
If true
, desired
will be interpreted as the new number of buckets.
If false
, desired
will be interpreted as the new desired load factor.
false
by default.
When on_buckets
is false
, the new number of buckets is set to ceil(entries / desired)
.
Generated using TypeDoc
Hashmap class
Currently supports collision resolution by chaining, hashing by modulo and string keys
Todo
Add load-factor based rehashing
Todo
Add hashing by multiplication option