Optional
hashFn: HashFunction<K>Private
_bucketsPrivate
_capacityPrivate
_hashPrivate
_sizeStatic
Private
Readonly
DEFAULT_Static
Private
Readonly
LOAD_Protected
_defaultThe key
parameter is the input value that needs to be hashed. It can be of any type, but in this
code snippet, it is checked whether the key is a string or an object. If it is a string, the _murmurStringHashFn
function is used to
the hash value of the key modulo the capacity of the data structure.
Protected
_expandProtected
_hashProtected
_multiplicativeThe _multiplicativeStringHashFn
function calculates a hash value for a given string key using the multiplicative
string hash function.
The key
parameter is the input value for which we want to calculate the hash. It can be of any
type, as it is generic (K
). The function converts the key
to a string using the String()
function.
a number, which is the result of the multiplicative string hash function applied to the input key.
Protected
_murmurThe function _murmurStringHashFn
calculates a hash value for a given string key using the MurmurHash algorithm.
The key
parameter is the input value for which you want to calculate the hash. It can be of any
type, but it will be converted to a string using the String()
function before calculating the hash.
a number, which is the hash value calculated for the given key.
Protected
_objectThe function _objectHash
takes a key and returns a hash value, using a custom hash function for objects.
The parameter "key" is of type "K", which means it can be any type. It could be a string, number, boolean, object, or any other type of value. The purpose of the objectHash function is to generate a hash value for the key, which can be used for
a number, which is the hash value of the key.
Protected
_stringThe function calculates a hash value for a given string using the djb2 algorithm.
The key
parameter in the stringHash
function is a string value that represents the input for
which we want to calculate the hash value.
a number, which is the hash value of the input string.
The get
function retrieves the value associated with a given key from a hash table.
The key
parameter represents the key of the element that we want to retrieve from the data
structure.
The method is returning the value associated with the given key if it exists in the hash table. If the key is
not found, it returns undefined
.
The remove function removes a key-value pair from a hash table.
The key
parameter represents the key of the key-value pair that needs to be removed from the hash
table.
Nothing is being returned. The remove
method has a return type of void
, which means it does not return
any value.
The set function adds a key-value pair to the hash table, handling collisions and resizing if necessary.
The key parameter represents the key of the key-value pair that you want to insert into the hash table. It is of type K, which is a generic type representing the key's data type.
The parameter val
represents the value that you want to associate with the given key in the hash
table.
Nothing is being returned. The return type of the put
method is void
, which means it does not return any
value.
Generated using TypeDoc
The function
_defaultHashFn
calculates the hash value of a given key and returns the remainder when divided by the capacity of the data structure.