/hashmap

Primary LanguageJavaScript

Hashmap

Method:

  • hash(key) produces a hash code with it.
  • set(key, value) assign value with key to hashmap. If a key already exists, then the old value is overwritten.
  • get(key) returns the value that is assigned to this key. If a key is not found, return null.
  • has(key) returns true or false based on whether or not the key is in the hash map.
  • remove(key) If the given key is in the hash map, it should remove the entry with that key and return true. If the key isn’t in the hash map, it should return false.
  • length() returns the number of stored keys in the hash map.
  • clear() removes all entries in the hash map.
  • keys() returns an array containing all the keys inside the hash map.
  • values() returns an array containing all the values.
  • entries() returns an array that contains each key, value pair.