Class powersoft.jcm.util.Multimap
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class powersoft.jcm.util.Multimap

java.lang.Object
   |
   +----powersoft.jcm.util.Multimap

public class Multimap
extends Object
implements Cloneable
Encapsulates a multi-mapped dictionary. A multi-map is a dictionary in which key can be mapped to one or more values.

See Also:
Dictionary

Constructor Index

 o Multimap()
Constructs a new, empty multi-map.
 o Multimap(Hashtable)
Creates a new multi-map with the initial internal hash-table
 o Multimap(int)
Constructs a new, empty multi-map with the specified initial capacity.
 o Multimap(int, float)
Constructs a new, empty multi-map with the specified initial capacity and the specified load factor.

Method Index

 o clear()
Clears the multi-map so that it has no more mappings in it.
 o clone()
Creates a clone of the multi-map.
 o contains(Object, Object)
Tests whether the multimap contains the map mapping the key to the value.
 o containsKey(Object)
Returns true if the collection contains a mapping for the key.
 o counts(Object)
Counts how many maps there are for a key.
 o get(Object)
Retrieves the elements to which the key is mapped.
 o get(Object, int)
Get the object associated with the specified key in the multi-map with the specified index.
 o isEmpty()
Returns true if the multi-map contains no mapping.
 o keys()
Returns an enumeration of the multi-map's keys.
 o put(Object, Object)
Puts the specified mapping into the multi-map, using the specified key.
 o remove(Object)
Removes all the mappings corresponding to the key.
 o remove(Object, int)
Removes a mapping at a particular index associated with the key.
 o remove(Object, Object)
Removes the mapping from the key to the value.
 o size()
Returns the number of keys in the multi-map.
 o toString()
Converts to a rather lengthy string.

Constructors

 o Multimap
  public Multimap()
Constructs a new, empty multi-map. A default capacity and load factor is used. Note that the multi-map will automatically grow when it gets full.
 o Multimap
  public Multimap(int initialCapacity)
Constructs a new, empty multi-map with the specified initial capacity.
Parameters:
initialCapacity - the initial number of buckets
Throws: IllegalArgumentException
If the initial capacity is less than or equal to zero.
 o Multimap
  public Multimap(int initialCapacity,
                  float loadFactor)
Constructs a new, empty multi-map with the specified initial capacity and the specified load factor.
Parameters:
initialCapacity - the initial number of buckets
loadFactor - a number between 0.0 and 1.0, it defines the threshold for rehashing the multi-map into a bigger one.
Throws: IllegalArgumentException
If the initial capacity is less than or equal to zero.
Throws: IllegalArgumentException
If the load factor is less than or equal to zero.
 o Multimap
  protected Multimap(Hashtable hashtable)
Creates a new multi-map with the initial internal hash-table

Methods

 o clear
  public void clear()
Clears the multi-map so that it has no more mappings in it.
 o size
  public int size()
Returns the number of keys in the multi-map.
 o isEmpty
  public boolean isEmpty()
Returns true if the multi-map contains no mapping.
 o put
  public synchronized void put(Object key,
                               Object value)
Puts the specified mapping into the multi-map, using the specified key. Neither the key nor the value may be null.
Parameters:
key - the specified key in the multi-map
value - the specified element
Throws: NullPointerException
If the value of the key or value is equal to null.
See Also:
get
 o get
  public synchronized Enumeration get(Object key)
Retrieves the elements to which the key is mapped.
Parameters:
key - Specifies the key of the elements to be retrieved.
Returns:
An enumeration of the values in the multi-map.
 o get
  public synchronized Object get(Object key,
                                 int index)
Get the object associated with the specified key in the multi-map with the specified index.
Parameters:
key - A key in the hash table.
index - The index of the value.
Returns:
The specific value to which the key is mapped in this hash table; null if the key is not defined in the multi-map or index is out of range.
 o counts
  public int counts(Object key)
Counts how many maps there are for a key.
 o containsKey
  public boolean containsKey(Object key)
Returns true if the collection contains a mapping for the key.
Parameters:
key - The key to test.
See Also:
contains
 o contains
  public synchronized boolean contains(Object key,
                                       Object value)
Tests whether the multimap contains the map mapping the key to the value.
Parameters:
key - Specifies the key to test.
value - Specifies the value to test.
See Also:
containsKey
 o remove
  public boolean remove(Object key)
Removes all the mappings corresponding to the key. Does nothing if the key is not present.
Parameters:
key - The key of the mappings to be removed.
Returns:
true If the original multi-map has mappings associated with the key.
 o remove
  public synchronized boolean remove(Object key,
                                     Object value)
Removes the mapping from the key to the value. Does nothing if the mapping does not exist in the multi-map.
Parameters:
key - The specified key.
value - The specified value.
Returns:
true If the original multi-map contains the mapping.
 o remove
  public synchronized boolean remove(Object key,
                                     int index)
Removes a mapping at a particular index associated with the key. Does nothing if the mapping does not exist in the multi-map or the specified index is out of range.
Parameters:
key - The specified key.
index - The specified index.
Returns:
true If the original multi-map contains the mapping at the index.
 o keys
  public Enumeration keys()
Returns an enumeration of the multi-map's keys. Use the Enumeration methods on the returned object to fetch the keys sequentially.
See Also:
get, Enumeration
 o toString
  public synchronized String toString()
Converts to a rather lengthy string.
Overrides:
toString in class Object
 o clone
  public synchronized Object clone()
Creates a clone of the multi-map. A shallow copy is made, the keys and elements themselves are NOT cloned. This is a relatively expensive operation.
Overrides:
clone in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index