Private
_bucketsPrivate
_capacityPrivate
_sizeThe get
function retrieves the value associated with a given key from a hash table.
The parameter "key" 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
.
Private
hashThe hash function takes a key, converts it to a string, calculates the sum of the ASCII values of its characters, and returns the remainder when divided by the capacity of the data structure.
The key
parameter represents the key that needs to be hashed. It is of type K
, which means it can
be any data type that can be converted to a string.
The hash value of the key modulo the capacity of the data structure.
The put function adds a key-value pair to a hash table, handling collisions by chaining.
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 can be any data type that can be used as a key, such as a string, number, or object.
The val
parameter represents the value associated with the key in the hash table.
Nothing is being returned. The return type of the function is void, which means it does not return any value.
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.
Generated using TypeDoc
The constructor initializes the capacity, size, and buckets of an object.