lab4
Interface MultiMap

All Known Implementing Classes:
CollectionMap, MultiHashMap

public interface MultiMap

MultiMap is an interface designed for Objects that associate multiple values with a single key.

Specification Fields :
bindings : set[(Object, Collection)] //the connections stored by this map
Derived Fields

Method Summary
 void clear()
          Removes all bindings maintained by this map
 boolean contains(Object key, Object value)
          Returns true iff this mapping maps key to value
 boolean containsKey(Object key)
          Checks to see if this map contains any bindings for key
 boolean containsValue(Object value)
          Checks to see if this map contains any bindings to this value
 boolean equals(Object o)
          Compares the specified Object with this map for equality
 Collection getAll(Object key)
          Returns an unmodifiable Collection snapshot of all mappings from key
 boolean isEmpty()
          Returns true iff this mapping contains no associations
 void putAll(Object key, Collection values)
          Adds an association from key to each value contained by values
 boolean remove(Object key, Object value)
          Removes a binding from key to value.
 

Method Detail

contains

public boolean contains(Object key,
                        Object value)
Returns true iff this mapping maps key to value

Returns:
true iff getAll(key).contains(value)

getAll

public Collection getAll(Object key)
Returns an unmodifiable Collection snapshot of all mappings from key

Returns:
an unmodifiable Collection snapshot of all mappings from key

putAll

public void putAll(Object key,
                   Collection values)
Adds an association from key to each value contained by values

Requires:
values != null
Effects:
for all v in values, put(key, v)

remove

public boolean remove(Object key,
                      Object value)
Removes a binding from key to value.

Returns:
true iff key was associated with value

isEmpty

public boolean isEmpty()
Returns true iff this mapping contains no associations

Returns:
true iff this mapping contains no associations

equals

public boolean equals(Object o)
Compares the specified Object with this map for equality

Overrides:
equals in class Object
Returns:
true iff o.bindings = this.bindings

containsKey

public boolean containsKey(Object key)
Checks to see if this map contains any bindings for key

Returns:
true iff key is an element of this.keys

containsValue

public boolean containsValue(Object value)
Checks to see if this map contains any bindings to this value

Returns:
true iff value is an element of values

clear

public void clear()
Removes all bindings maintained by this map

Effects:
for all k in keys and v in values, remove(k, v)