|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.modeshape.common.collection.LinkedListMultimap<K,V>
K - the key typeV - the value typepublic final class LinkedListMultimap<K,V>

A Multimap implementation that uses an LinkedList to store the values associated with a key. This
implementation allows duplicate values for a key, maintains the insertion-order of the values for each key
, and maintains the insertion order of all key-value pairs.
| Nested Class Summary | |
|---|---|
protected static class |
LinkedListMultimap.Entry<K,V>
|
protected class |
LinkedListMultimap.EntryIterator
|
protected class |
LinkedListMultimap.KeyIterator
|
protected class |
LinkedListMultimap.MapEntries
|
protected class |
LinkedListMultimap.MapView
|
protected class |
LinkedListMultimap.ValueIterator
|
| Field Summary | |
|---|---|
protected LinkedListMultimap.Entry<K,V> |
firstEntry
|
protected Map<K,LinkedListMultimap.Entry<K,V>> |
firstEntryWithKey
|
protected LinkedListMultimap.Entry<K,V> |
lastEntry
|
protected Map<K,LinkedListMultimap.Entry<K,V>> |
lastEntryWithKey
|
protected int |
length
|
protected Map<K,AtomicInteger> |
numberOfEntriesForKey
|
| Constructor Summary | |
|---|---|
protected |
LinkedListMultimap()
|
| Method Summary | ||
|---|---|---|
protected LinkedListMultimap.Entry<K,V> |
addEntryFor(K key,
V value)
|
|
Map<K,Collection<V>> |
asMap()
Return a map view that associates each key with the corresponding values in the multimap. |
|
void |
clear()
Remove all key-value pairs from this multimap. |
|
boolean |
containsEntry(Object key,
Object value)
Determine whether this multimap contains the supplied key-value pair. |
|
boolean |
containsKey(K key)
Determine whether this multimap associates any values with the supplied key. |
|
boolean |
containsValue(Object value)
Determine whether this multimap associates at least one key with the supplied value. |
|
static
|
create()
Creates a new, empty LinkedListMultimap with the default initial capacity. |
|
protected int |
currentCountFor(K key)
|
|
protected int |
decrementEntryCountFor(K key)
|
|
Collection<Map.Entry<K,V>> |
entries()
Return a collection of all key-value pairs. |
|
boolean |
equals(Object obj)
|
|
List<V> |
get(K key)
Get the collection of values that are associated with the supplied key. |
|
int |
hashCode()
|
|
protected int |
incrementEntryCountFor(K key)
|
|
protected LinkedListMultimap.Entry<K,V> |
insertEntryBefore(K key,
V value,
LinkedListMultimap.Entry<K,V> nextEntryWithKey)
|
|
boolean |
isEmpty()
|
|
protected void |
isValid(LinkedListMultimap.Entry<K,V> entry)
|
|
Set<K> |
keySet()
Return the set of keys in this multimap. |
|
boolean |
put(K key,
V value)
Associate the supplied value with the given key, returning true if the size of this multimap was increased. |
|
boolean |
remove(K key,
V value)
Remove the supplied key-value pair from this multi-map. |
|
Collection<V> |
removeAll(K key)
Remove all of the key-value pairs that use the supplied key, returning the collection of values. |
|
protected void |
removeEntry(LinkedListMultimap.Entry<K,V> entry)
|
|
int |
size()
Return the number of key-value pairs in this multimap. |
|
String |
toString()
|
|
Collection<V> |
values()
Return a collection of all values in this multimap. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected LinkedListMultimap.Entry<K,V> firstEntry
protected LinkedListMultimap.Entry<K,V> lastEntry
protected int length
protected final Map<K,AtomicInteger> numberOfEntriesForKey
protected final Map<K,LinkedListMultimap.Entry<K,V>> firstEntryWithKey
protected final Map<K,LinkedListMultimap.Entry<K,V>> lastEntryWithKey
| Constructor Detail |
|---|
protected LinkedListMultimap()
| Method Detail |
|---|
public static <K,V> LinkedListMultimap<K,V> create()
LinkedListMultimap with the default initial capacity.
K - the key typeV - the value type
public void clear()
clear in interface Multimap<K,V>Multimap.clear()public int size()
size in interface Multimap<K,V>Multimap.size()public boolean isEmpty()
isEmpty in interface Multimap<K,V>Multimap.isEmpty()public boolean containsKey(K key)
containsKey in interface Multimap<K,V>key - the key
true if there is at least one value associated with the supplied key, or false otherwiseMultimap.containsKey(java.lang.Object)
public boolean containsEntry(Object key,
Object value)
containsEntry in interface Multimap<K,V>key - the keyvalue - the value
true if this multimap contains an entry with the supplied key and value, or false otherwiseMultimap.containsEntry(java.lang.Object, java.lang.Object)public boolean containsValue(Object value)
containsValue in interface Multimap<K,V>value - the value
true if there is at least one key associated with the supplied value, or false otherwiseMultimap.containsValue(java.lang.Object)public List<V> get(K key)
Changes to the returned collection will update the values that this multimap associates with the key.
get in interface ListMultimap<K,V>get in interface Multimap<K,V>key - the key
ListMultimap.get(java.lang.Object)
public boolean put(K key,
V value)
Some implementations allow duplicate key-value pairs, and in these cases this method will always increase the size of the multimap and will thus always return true. Other implementations will not allow duplicate key-value pairs, and may return false if the multimap already contains the supplied key-value pair.
put in interface Multimap<K,V>key - the keyvalue - the value
true if the size of this multimap was increased as a result of this call, or false if the multimap
already contained the key-value pair and doesn't allow duplicatesMultimap.put(java.lang.Object, java.lang.Object)
public boolean remove(K key,
V value)
remove in interface Multimap<K,V>key - the keyvalue - the value
true if the size of this multimap was decreased as a result of this call, or false if the multimap
did not contain the key-value pairMultimap.remove(java.lang.Object, java.lang.Object)public Collection<V> removeAll(K key)
removeAll in interface Multimap<K,V>key - the key
Multimap.removeAll(java.lang.Object)public Collection<Map.Entry<K,V>> entries()
add or addAll operations.
entries in interface Multimap<K,V>Multimap.entries()public Set<K> keySet()
keySet in interface Multimap<K,V>Multimap.keySet()public Collection<V> values()
values in interface Multimap<K,V>Multimap.values()public Map<K,Collection<V>> asMap()
setValue() on its entries,
put, or putAll.
The collections returned by asMap().get(Object) have the same behavior as those returned by Multimap.get(K).
asMap in interface Multimap<K,V>Multimap.asMap()public int hashCode()
hashCode in class ObjectObject.hashCode()public boolean equals(Object obj)
equals in class ObjectObject.equals(java.lang.Object)public String toString()
toString in class ObjectObject.toString()protected int incrementEntryCountFor(K key)
protected int decrementEntryCountFor(K key)
protected int currentCountFor(K key)
protected LinkedListMultimap.Entry<K,V> addEntryFor(K key,
V value)
protected LinkedListMultimap.Entry<K,V> insertEntryBefore(K key,
V value,
LinkedListMultimap.Entry<K,V> nextEntryWithKey)
protected void removeEntry(LinkedListMultimap.Entry<K,V> entry)
protected void isValid(LinkedListMultimap.Entry<K,V> entry)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||