|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.groiss.ds.MultiMap<K,V>
public class MultiMap<K,V>
A MultiMap maps keys to objects, where one key can be mapped to a list of objects.
By default the MultiMap
is not threadsafe
there are two constructors where you can specify the concurrency settings MultiMap(boolean)
, MultiMap(boolean, int, int)
.
If nothing is specified, the multimap has an default initial capacity of 16 and an default subVectorSize of 16
Constructor Summary | |
---|---|
MultiMap()
Constructs an empty, not threadsafe MultiMap with default initialcapacity (16) and default subVectorSize (16) |
|
MultiMap(boolean threadSafe)
Constructs an empty MultiMap |
|
MultiMap(boolean threadSafe,
int capacity,
int initialVectorSize)
Constructs an empty MultiMap with the given settings |
|
MultiMap(int initialSubSize)
Constructs a MultiMap and specifies an initial size for the Vectors holding the values to the keys. |
|
MultiMap(int capacity,
int initialSubSize)
Creates a new MultiMap with the defined capacity and Vector size. |
Method Summary | |
---|---|
void |
clear()
Removes all mappings from this map |
boolean |
containsKey(java.lang.Object key)
Returns true if this map contains a mapping for the specified key. |
boolean |
containsValue(java.lang.Object value)
Returns true if this map maps one or more keys to the specified value. |
int |
count(java.lang.Object key)
Returns number of values mapped to a given key. |
java.util.Enumeration<java.util.List<V>> |
elements()
Returns the elements in the map |
java.util.Set<java.util.Map.Entry<K,java.util.List<V>>> |
entrySet()
Returns a set view of the mappings contained in this map. |
java.util.Enumeration<V> |
enumeration(java.lang.Object key)
Returns all values mapped to a given key, or null |
java.util.List<V> |
get(java.lang.Object key)
Returns the values to which this map maps the specified key or null if there's no mapping |
java.util.List<V> |
getEntries(java.lang.Object key)
Deprecated. since 8.0; use get(Object) instead |
java.util.List<V> |
getEntryList(java.lang.Object key)
returns a list containing all entries, mapped to the given key; if no value is mapped to this key, an empty list is returned |
boolean |
hasValue(java.lang.Object key,
java.lang.Object value)
Finds out if the object key has a mapping to the object
value . |
boolean |
isEmpty()
Returns true if this map contains no key-value mappings. |
java.util.Enumeration<K> |
keys()
Deprecated. since 8.0; use keySet() instead |
java.util.Set<K> |
keySet()
Returns a set view of the keys contained in this map. |
void |
put(K key,
V value)
Put the mapping of a key and an object to the map. |
void |
putAll(K key,
java.util.Collection<? extends V> values)
Adds all the values to the given key |
void |
putAll(java.util.Map<? extends K,? extends java.util.List<V>> t)
Copies all of the mappings from the specified map to this map |
java.util.List<V> |
remove(java.lang.Object key)
Removes the mapping for this key from this map if it is present |
boolean |
remove(java.lang.Object key,
java.lang.Object value)
Removes the value for a certain key. |
int |
size()
|
java.lang.String |
toString()
|
java.util.Collection<java.util.List<V>> |
values()
Returns a collection view of the values contained in this map. |
java.util.Set<V> |
valueSet()
Return all values in this map as a single flattened set. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public MultiMap()
public MultiMap(boolean threadSafe)
threadSafe
- whether the map is threadsafe or notpublic MultiMap(boolean threadSafe, int capacity, int initialVectorSize)
threadSafe
- capacity
- capacity of the mapinitialVectorSize
- capacity of the created collections to store the valuespublic MultiMap(int initialSubSize)
initialSubSize
- New Vectors will be created with this size.public MultiMap(int capacity, int initialSubSize)
capacity
- The Map will have this initial size. The load factor is the
standard value of 0.75.initialSubSize
- New Vectors will be created with this size.Method Detail |
---|
public void clear()
public boolean containsKey(java.lang.Object key)
key
- key whose presence in this map is to be tested.
public boolean containsValue(java.lang.Object value)
value
- value whose presence in this map is to be tested.
public int count(java.lang.Object key)
key
- the key object
public java.util.Enumeration<java.util.List<V>> elements()
public java.util.Enumeration<V> enumeration(java.lang.Object key)
key
- the key object
public java.util.Set<java.util.Map.Entry<K,java.util.List<V>>> entrySet()
Map.Entry
. The set is backed by the
map, so changes to the map are reflected in the set, and vice-versa.
public java.util.List<V> get(java.lang.Object key)
key
- key whose associated value is to be returned.
getEntryList(Object)
@Deprecated public java.util.List<V> getEntries(java.lang.Object key)
get(Object)
instead
get(Object)
public java.util.List<V> getEntryList(java.lang.Object key)
key
- the key
public boolean hasValue(java.lang.Object key, java.lang.Object value)
key
has a mapping to the object
value
.
key
- The key object.value
- The desired value object.
true
if the key object contains a mapping to the
given value object. In all other cases (also if the key doesn't
exist at all), false
will be returned.public boolean isEmpty()
@Deprecated public java.util.Enumeration<K> keys()
keySet()
instead
public java.util.Set<K> keySet()
public void put(K key, V value)
key
- a keyvalue
- the value object.public void putAll(K key, java.util.Collection<? extends V> values)
key
- the key to which the values should be addedvalues
- the valuespublic void putAll(java.util.Map<? extends K,? extends java.util.List<V>> t)
t
- Mappings to be stored in this map.public java.util.List<V> remove(java.lang.Object key)
key
- key whose mapping is to be removed from the map.
public boolean remove(java.lang.Object key, java.lang.Object value)
key
- the key objectvalue
- the value for the keypublic int size()
public java.lang.String toString()
toString
in class java.lang.Object
public java.util.Collection<java.util.List<V>> values()
public java.util.Set<V> valueSet()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |