Class BSTMap<K extends java.lang.Comparable<K>,V>
- java.lang.Object
-
- BSTMap<K,V>
-
-
Constructor Summary
Constructors Constructor Description BSTMap()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsKey(K key)
Returns true if the key has been put into this map (and not removed).V
get(K key)
Retrieves the value associated with the given key.void
put(K key, V value)
Associates the given value to the given key.void
remove(K key)
Removes the key and any associated value from the map, if present.int
size()
Returns the number of distinct keys that have been put in the map (and not yet removed).java.util.Deque<K>
traverse()
Returns a new Deque with all of the keys of this map.
-
-
-
Method Detail
-
get
public V get(K key)
Description copied from interface:Map
Retrieves the value associated with the given key. If the key is not in the map, null is returned.
-
containsKey
public boolean containsKey(K key)
Description copied from interface:Map
Returns true if the key has been put into this map (and not removed).- Specified by:
containsKey
in interfaceMap<K extends java.lang.Comparable<K>,V>
-
put
public void put(K key, V value)
Description copied from interface:Map
Associates the given value to the given key. If the key was not in the map, it is added and the size increases. Otherwise the size stays the same, but the new value should update the value previously associated to that key.
-
size
public int size()
Description copied from interface:Map
Returns the number of distinct keys that have been put in the map (and not yet removed).
-
traverse
public java.util.Deque<K> traverse()
Description copied from interface:Map
Returns a new Deque with all of the keys of this map. When feasible based on the underlying data structure (such as a binary search tree), the keys should be added to the tail end of the Deque in sorted order.
-
-