|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.rim.device.api.util.IntMultiMap
public class IntMultiMap
Provides a one to many mapping between an integer key and some values.
Constructor Summary | ||
---|---|---|
IntMultiMap()
Constructs a new IntMultiMap instance. |
||
IntMultiMap(int initialCapacity,
boolean allowDuplicates)
Constructs a new IntMultiMap instance with the provided capacity. |
Method Summary | ||
---|---|---|
void |
add(int key,
Object value)
Maps value to key. |
|
void |
clear()
Removes all keys and values. |
|
boolean |
containsKey(int key)
Determines if key is mapped. |
|
boolean |
containsValue(int key,
Object value)
Determines if value is mapped to key. |
|
Enumeration |
elements()
Retrieves an enumeration of the values in this map. |
|
Enumeration |
elements(int key)
Retrieves an enumeration of values for a key. |
|
protected int |
findKey(int key)
Returns > 0 if key is found, or < 0 if key is not found. |
|
boolean |
isEmpty()
Determines if this map is empty. |
|
IntEnumeration |
keys()
Retrieves an enumeration of the keys in this map. |
|
boolean |
removeKey(int key)
Removes values by key. |
|
boolean |
removeValue(int key,
Object value)
Removes value by key from map. |
|
boolean |
removeValue(Object value)
Removes value from map. |
|
int |
size()
Retrieves the number of keys in this map. |
|
int |
size(int key)
Retrieves number of values for a key. |
|
void |
trim()
Releases any extra memory. |
|
protected void |
verifySorted()
Sorts the array of values. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public IntMultiMap(int initialCapacity, boolean allowDuplicates)
initialCapacity
- Starting capacity for this map.allowDuplicates
- If true, then duplicate key-value mappings are
allowed, otherwise duplicates are ignored. It is more efficient to allow
duplicate mappings, if possible. Two key-value mappings, say i
and j
are considered duplicate iff key[i] == key[j] && value[i].equals( value[j] )
public IntMultiMap()
This method creates a new multi map with an initial capacity of 16, and ignores duplicate key-value mappings.
Method Detail |
---|
public boolean isEmpty()
public void clear()
public void trim()
Invoke this method to trim off any underlying storage allocated by not used by this multimap.
public void add(int key, Object value)
key
- Key to associate with value; if this key already exists in the
map, the provided value is added to its association list.value
- Value to associate with key.protected void verifySorted()
protected int findKey(int key)
public boolean removeKey(int key)
key
- Key for value(s) to remove.
public boolean removeValue(int key, Object value)
If the value to remove is the last one associated with the key, then this method removes the key as well. Otherwise, this method removes only the value from the map; the key and its associations with other values remains.
key
- Key associated with value.value
- Value to remove.
public boolean removeValue(Object value)
Invoke this method to remove a value from this map when you don't
know its associated key. If you do know the key associated with this
value, then you should invoke the more efficient
IntMultiMap.removeValue(int,Object)
.
If the value to remove is the last one associated with its key, then this method removes the key as well. Otherwise, this method removes only the value from the map; the key and its associations with other values remains.
value
- Value to remove.
public boolean containsKey(int key)
key
- Key to check.
public boolean containsValue(int key, Object value)
key
- Key to check.value
- Value to check.
public IntEnumeration keys()
IntEnumeration
,
IntMultiMap.elements(int)
public Enumeration elements(int key)
key
- Key associated with values.
Enumeration
public Enumeration elements()
Enumeration
,
IntMultiMap.keys()
public int size()
Note that this method gives you the number of keys contained in the map, not the number of values in the map (which could be larger).
public int size(int key)
key
- Key in question.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal