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 booleancontainsKey(K key)Returns true if the key has been put into this map (and not removed).Vget(K key)Retrieves the value associated with the given key.voidput(K key, V value)Associates the given value to the given key.voidremove(K key)Removes the key and any associated value from the map, if present.intsize()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:MapRetrieves 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:MapReturns true if the key has been put into this map (and not removed).- Specified by:
containsKeyin interfaceMap<K extends java.lang.Comparable<K>,V>
-
put
public void put(K key, V value)
Description copied from interface:MapAssociates 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:MapReturns 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:MapReturns 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.
-
-