Less than 1 minute
Home > @hz-9/algorithm > Hashmap > set
Hashmap.set() method
Adds a key-value pair to the hash map.
将键值对添加到哈希表中。
Time complexity: O(1)
Space complexity: O(1)
Signature:
abstract set(key: K, value: V): boolean;Parameters
Parameter | Type | Description |
|---|---|---|
key | K | The key object. |
value | V | The value information. |
Returns:
boolean
Whether the addition is successful. Returns false if the key already exists.