structure
Class MapBST

java.lang.Object
  extended by structure.MapBST
All Implemented Interfaces:
Map, OrderedMap

public class MapBST
extends java.lang.Object
implements OrderedMap


Field Summary
protected  BinarySearchTree data
           
 
Constructor Summary
MapBST()
           
MapBST(java.util.Comparator ordering)
           
 
Method Summary
 void clear()
           
 boolean containsKey(java.lang.Object k)
           
 boolean containsValue(java.lang.Object v)
           
 Set entrySet()
           
 boolean equals(java.lang.Object other)
           
 java.lang.Object get(java.lang.Object k)
           
 int hashCode()
           
 boolean isEmpty()
           
 Set keySet()
           
 java.lang.Object put(java.lang.Object k, java.lang.Object v)
           
 void putAll(Map other)
           
 java.lang.Object remove(java.lang.Object k)
           
 int size()
           
 Structure values()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

data

protected BinarySearchTree data
Constructor Detail

MapBST

public MapBST(java.util.Comparator ordering)

MapBST

public MapBST()
Method Detail

size

public int size()
Specified by:
size in interface Map
Postcondition:
returns the number of entries in the map

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Map
Postcondition:
returns true iff this map does not contains any entries

containsKey

public boolean containsKey(java.lang.Object k)
Specified by:
containsKey in interface Map
Precondition:
k is non-null
Postcondition:
returns true iff k is a key that is mapped to a value; that is, k is in the domain of the map

containsValue

public boolean containsValue(java.lang.Object v)
Specified by:
containsValue in interface Map
Precondition:
v is non-null
Postcondition:
returns true iff v is the target of at least one map entry; that is, v is in the range of the map

get

public java.lang.Object get(java.lang.Object k)
Specified by:
get in interface Map
Precondition:
k is a key, possibly in the map
Postcondition:
returns the value mapped to from k, or null

put

public java.lang.Object put(java.lang.Object k,
                            java.lang.Object v)
Specified by:
put in interface Map
Precondition:
k and v are non-null
Postcondition:
inserts a mapping from k to v in the map

remove

public java.lang.Object remove(java.lang.Object k)
Specified by:
remove in interface Map
Precondition:
k is non-null
Postcondition:
removes any mapping from k to a value, from the mapping

putAll

public void putAll(Map other)
Specified by:
putAll in interface Map
Precondition:
other is non-null
Postcondition:
all the mappings of other are installed in this map, overriding any conflicting maps

clear

public void clear()
Specified by:
clear in interface Map
Postcondition:
removes all map entries associated with this map

keySet

public Set keySet()
Specified by:
keySet in interface Map
Postcondition:
returns a set of all keys associated with this map

values

public Structure values()
Specified by:
values in interface Map
Postcondition:
returns a structure that contains the range of the map

entrySet

public Set entrySet()
Specified by:
entrySet in interface Map
Postcondition:
returns a set of (key-value) pairs, generated from this map

equals

public boolean equals(java.lang.Object other)
Specified by:
equals in interface Map
Overrides:
equals in class java.lang.Object
Precondition:
other is non-null
Postcondition:
returns true iff maps this and other are entry-wise equal

hashCode

public int hashCode()
Specified by:
hashCode in interface Map
Overrides:
hashCode in class java.lang.Object
Postcondition:
returns a hash code associated with this structure