weiss.util
Interface Map

All Superinterfaces:
java.io.Serializable
All Known Implementing Classes:
weiss.util.MapImpl

public interface Map
extends java.io.Serializable

Map interface. A map stores key/value pairs. In our implementations, duplicate keys are not allowed.


Inner Class Summary
static interface Map.Entry
          The interface used to access the key/value pairs in a map.
 
Method Summary
 void clear()
          Removes all key value pairs from the map.
 boolean containsKey(java.lang.Object key)
          Tests if this map contains a given key.
 Set entrySet()
          Return a set of Map.Entry objects corresponding to the key/value pairs in the map.
 java.lang.Object get(java.lang.Object key)
          Returns the value in the map associated with the key.
 boolean isEmpty()
          Tests if this map is empty.
 Set keySet()
          Returns the keys in the map.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Adds the key value pair to the map, overriding the original value if the key was already present.
 java.lang.Object remove(java.lang.Object key)
          Remove the key and its value from the map.
 int size()
          Returns the number of keys in this map.
 Collection values()
          Returns the values in the map.
 

Method Detail

size

public int size()
Returns the number of keys in this map.
Returns:
the number of keys in this collection.

isEmpty

public boolean isEmpty()
Tests if this map is empty.
Returns:
true if the size of this map is zero.

containsKey

public boolean containsKey(java.lang.Object key)
Tests if this map contains a given key.
Parameters:
key - the key to search for.
Returns:
true if the map contains the key.

get

public java.lang.Object get(java.lang.Object key)
Returns the value in the map associated with the key.
Parameters:
key - the key to search for.
Returns:
the value that matches the key or null if the key is not found. Since null values are allowed, checking if the return value is null may not be a safe way to ascertain if the key is present in the map.

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Adds the key value pair to the map, overriding the original value if the key was already present.
Parameters:
key - the key to insert.
value - the value to insert.
Returns:
the old value associated with the key, or null if the key was not present prior to this call.

remove

public java.lang.Object remove(java.lang.Object key)
Remove the key and its value from the map.
Parameters:
key - the key to remove.
Returns:
the previous value associated with the key, or null if the key was not present prior to this call.

clear

public void clear()
Removes all key value pairs from the map.

keySet

public Set keySet()
Returns the keys in the map.

values

public Collection values()
Returns the values in the map. There may be duplicates.

entrySet

public Set entrySet()
Return a set of Map.Entry objects corresponding to the key/value pairs in the map.