chen-w
7/13/2017 - 7:43 PM

hash operations

hash operations

// Create a new hashtable
HashMap<Integer, Integer> map = new HashMap<Interger, Interger>();
HashMap<String, Integer> map = new HashMap<String, Interger>();

// add element
map.put(key, value)

// remove element
map.remove(key)

// access element
map.get(key)

// check element
map.containsKey(key)
map.contrainsValue(value)

// size
map.size()

// clear all maps
map.clear()

// is empty
map.isEmpty()

// 	get value of return default value
getOrDefault(Object key, V defaultValue)
Returns the value to which the specified key is mapped, or defaultValue if this map contains no mapping for the key.

// get all key
hash.keySet()