uwcse.collections
Interface SimpleMap

All Known Implementing Classes:
SimpleClosedHashMap, SimpleListMap, SimpleOpenHashMap

public interface SimpleMap

An simple map interface. A map is an unordered collection that associates keys with values. The keys in the table must form a set, that is, there may not be duplicates. Multiple keys may map to the same value, however. Finally, null is neither a valid key nor value.


Method Summary
 void clear()
          Remove all associations from the map.
 boolean containsKey(java.lang.Object key)
          Answer true iff the given key exists in the map.
 boolean containsValue(java.lang.Object value)
          Answer true iff the given value exists in the map.
 java.lang.Object get(java.lang.Object key)
          Answer the value associated with the given key.
 boolean isEmpty()
          Answer (size() == 0)
 SimpleIterator keys()
          Answer a SimpleIterator over the keys in the association.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Associate the given key and value, replacing any previous association for the given key.
 java.lang.Object remove(java.lang.Object key)
          Remove the association (if any) for the given key.
 int size()
          Answer the number of associations in the map.
 SimpleIterator values()
          Answer a SimpleIterator over the values in the association.
 

Method Detail

clear

public void clear()
Remove all associations from the map.

containsKey

public boolean containsKey(java.lang.Object key)
Answer true iff the given key exists in the map.

containsValue

public boolean containsValue(java.lang.Object value)
Answer true iff the given value exists in the map.

get

public java.lang.Object get(java.lang.Object key)
Answer the value associated with the given key.
Returns:
null if the key is not in the map

isEmpty

public boolean isEmpty()
Answer (size() == 0)

keys

public SimpleIterator keys()
Answer a SimpleIterator over the keys in the association.

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Associate the given key and value, replacing any previous association for the given key.
Returns:
the result of get(key) before the new association is made

remove

public java.lang.Object remove(java.lang.Object key)
Remove the association (if any) for the given key.
Returns:
the result of get(key) before the removal takes place

size

public int size()
Answer the number of associations in the map.

values

public SimpleIterator values()
Answer a SimpleIterator over the values in the association.