Constructor
new HashTable()
Start with an empty array and store the length of the "hashtable".
- Source:
Methods
(static) hashKey(key) → {number}
Accepts a string and outputs a (mostly) unique address that will be used in other functions of this class.
Parameters:
| Name | Type | Description |
|---|---|---|
key |
String | Key to get hashed |
- Source:
Throws:
-
-
Key can not be undefined!
- Type
- ReferenceError
-
-
-
The key needs to be type of string!
- Type
- TypeError
-
Returns:
- Type
- number
get(key) → {*}
Retrieve the value of a given key. Hash the key and get value from "memory".
Parameters:
| Name | Type | Description |
|---|---|---|
key |
String | Key to retrieve value |
- Source:
Throws:
-
-
Key can not be undefined!
- Type
- ReferenceError
-
-
-
The key needs to be type of string!
- Type
- TypeError
-
Returns:
- Type
- *
remove(key)
Remove a pair of data.
Parameters:
| Name | Type | Description |
|---|---|---|
key |
String | Key of pair that should be removed |
- Source:
Throws:
-
-
Key can not be undefined!
- Type
- ReferenceError
-
-
-
The key needs to be type of string!
- Type
- TypeError
-
set(key, value)
Set value for key. Hash the key and set value in "memory".
Parameters:
| Name | Type | Description |
|---|---|---|
key |
String | Key |
value |
* | Value for given key |
- Source:
Throws:
-
-
Key can not be undefined!
- Type
- ReferenceError
-
-
-
The key needs to be type of string!
- Type
- TypeError
-