jsdsi.util
Class MultiMap

java.lang.Object
  extended byjsdsi.util.MultiMap

public 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.2.2 $ $Date: 2005/11/08 03:12:52 $
Author:
Sameer Ajmani, Sean Radford

Constructor Summary
MultiMap()
           
 
Method Summary
 java.util.Set get(java.lang.Object key)
          Returns the Set for a given key.
 boolean isEmpty()
          Returns true if this MultiMap contains no elements.
 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.
 int size()
          Returns the number of elements in this MultiMap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiMap

public 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.

size

public int size()
Returns the number of elements in this MultiMap

Returns:
the number of elements in this MultiMap.

isEmpty

public boolean isEmpty()
Returns true if this MultiMap contains no elements.

Returns:
true if this MultiMap contains no elements.


Copyright © 2002-2006 JSDSI. All Rights Reserved.