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
-
Multimap()
- Constructs a new, empty multi-map.
-
Multimap(Hashtable)
- Creates a new multi-map with the initial internal hash-table
-
Multimap(int)
- Constructs a new, empty multi-map with the specified initial
capacity.
-
Multimap(int, float)
- Constructs a new, empty multi-map with the specified initial
capacity and the specified load factor.
-
clear()
- Clears the multi-map so that it has no more mappings in it.
-
clone()
- Creates a clone of the multi-map.
-
contains(Object, Object)
- Tests whether the multimap contains the map mapping the key to
the value.
-
containsKey(Object)
- Returns true if the collection contains a mapping for the key.
-
counts(Object)
- Counts how many maps there are for a key.
-
get(Object)
- Retrieves the elements to which the key is mapped.
-
get(Object, int)
- Get the object associated with the specified key in the multi-map
with the specified index.
-
isEmpty()
- Returns true if the multi-map contains no mapping.
-
keys()
- Returns an enumeration of the multi-map's keys.
-
put(Object, Object)
- Puts the specified mapping into the multi-map, using the specified
key.
-
remove(Object)
- Removes all the mappings corresponding to the key.
-
remove(Object, int)
- Removes a mapping at a particular index associated with the key.
-
remove(Object, Object)
- Removes the mapping from the key to the value.
-
size()
- Returns the number of keys in the multi-map.
-
toString()
- Converts to a rather lengthy string.
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.
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.
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.
Multimap
protected Multimap(Hashtable hashtable)
- Creates a new multi-map with the initial internal hash-table
clear
public void clear()
- Clears the multi-map so that it has no more mappings in it.
size
public int size()
- Returns the number of keys in the multi-map.
isEmpty
public boolean isEmpty()
- Returns true if the multi-map contains no mapping.
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
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.
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.
counts
public int counts(Object key)
- Counts how many maps there are for a key.
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
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
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.
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.
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.
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
toString
public synchronized String toString()
- Converts to a rather lengthy string.
- Overrides:
- toString in class Object
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