searchTree
Class SearchTreeMap<K extends java.lang.Comparable<K>,V>

java.lang.Object
  extended by searchTree.SearchTreeMap<K,V>

@DefaultAnnotationForParameters(value=edu.umd.cs.findbugs.annotations.Nullable.class)
public class SearchTreeMap<K extends java.lang.Comparable<K>,V>
extends java.lang.Object

This class provides a partial implementation of the Map interface. The implementation uses classes implementing the Tree interface to represent the actual search tree. All the methods of this class have been implemented, except keyList and subMap.


Constructor Summary
SearchTreeMap()
           
 
Method Summary
 V get(K k)
          Find the value the key is mapped to
 K getMax()
          Return the maximum key value in the set
 K getMin()
          Return the minimum key value in the set
 java.util.List<K> keyList()
          Return list of keys in map in natural/incresing sorted order
 java.util.Set<K> keySet()
          Return a Set of all the keys in the map
 void put(K k, V v)
          Update the mapping for the key
 void remove(K k)
          Remove any existing binding for a key
 int size()
          Return number of keys bound by this map
 SearchTreeMap<K,V> subMap(K fromKey, K toKey)
          Return subset of TreeMap between the values fromKey-toKey.
 java.lang.String toString()
          Return a string representation of the tree
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SearchTreeMap

public SearchTreeMap()
Method Detail

get

@CheckForNull
public V get(K k)
Find the value the key is mapped to

Parameters:
k - - Search key
Returns:
value k is mapped to, or null if there is no mapping for the key

put

public void put(K k,
                V v)
Update the mapping for the key

Parameters:
k - - key value
v - - value the key should be bound to

size

public int size()
Return number of keys bound by this map

Returns:
number of keys bound by this map

remove

public void remove(K k)
Remove any existing binding for a key

Parameters:
k - - key to be removed from the map

keySet

public java.util.Set<K> keySet()
Return a Set of all the keys in the map

Returns:
Set of all the keys in the map

getMin

@CheckForNull
public K getMin()
Return the minimum key value in the set

Returns:
the minimum key value in the set, or null if the set is empty

getMax

@CheckForNull
public K getMax()
Return the maximum key value in the set

Returns:
the maximum key value in the set, or null if the set is empty

toString

public java.lang.String toString()
Return a string representation of the tree

Overrides:
toString in class java.lang.Object

keyList

public java.util.List<K> keyList()
Return list of keys in map in natural/incresing sorted order

Returns:
list of keys in map in sorted order

subMap

public SearchTreeMap<K,V> subMap(K fromKey,
                                 K toKey)
Return subset of TreeMap between the values fromKey-toKey. It will include fromKey and toKey if they are found in the original map. The values for fromKey and toKey do not actually need to be in the map. You can assume than fromKey is less than or equal to toKey.

Returns:
TreeMap consisting of subset of SearchTreeMap


Web Accessibility