jsdsi
Class MultiMap

java.lang.Object
  extended byjsdsi.MultiMap

class MultiMap
extends java.lang.Object

A one-to-many map: each key is associated with a set of values. Note that get(key) returns the empty set if no value has previously been put() for that key.

Version:
$Revision: 1.1 $ $Date: 2004/02/28 15:49:34 $
Author:
Sameer Ajmani

Field Summary
(package private)  java.util.Map map
          Stores the key -> Set bindings.
 
Constructor Summary
(package private) MultiMap()
           
 
Method Summary
 java.util.Set get(java.lang.Object key)
          Returns the Set for a given key.
 void put(java.lang.Object key, java.lang.Object value)
          Adds a Set for a given key to this MultiMap.
 void putAll(java.lang.Object key, java.util.Collection coll)
          Adds the elements of a given collection to the set for a given key in this MultiMap.
 void remove(java.lang.Object key, java.lang.Object value)
          Remove an object from the set added with the key key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

map

java.util.Map map
Stores the key -> Set bindings.

Constructor Detail

MultiMap

MultiMap()
Method Detail

get

public java.util.Set get(java.lang.Object key)
Returns the Set for a given key. If the key hasn't been previously inserted with the put-method an empty set is returned.

Parameters:
key - key so return the set for.
Returns:
the set that has been added with key key previously.
See Also:
put(Object, Object)

put

public void put(java.lang.Object key,
                java.lang.Object value)
Adds a Set for a given key to this MultiMap.

Parameters:
key - key to add the set for.
value - set to add with key key.

putAll

public void putAll(java.lang.Object key,
                   java.util.Collection coll)
Adds the elements of a given collection to the set for a given key in this MultiMap.

Parameters:
key - key to add the collections for.
coll - collection to add for key.

remove

public void remove(java.lang.Object key,
                   java.lang.Object value)
Remove an object from the set added with the key key.

Parameters:
key - key of set to remove value from.
value - value to remove from the set that has been put with key key.


Copyright © 2002-2004 M.I.T. All Rights Reserved.