Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ModeShape Distribution 3.0.0.Alpha6
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.modeshape.common.collection
Class LinkedListMultimap<K,V>

    java.lang.Object
      org.modeshape.common.collection.LinkedListMultimap<K,V>

Type Parameters:
  `K` - the key type
  `V` - the value type

All Implemented Interfaces:
  ListMultimap<K,V>, Multimap<K,V>

    public final class LinkedListMultimap<K,V>

extends Object
implements ListMultimap<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
`<K,V> LinkedListMultimap<K,V>`
` | `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

### firstEntry

    protected LinkedListMultimap.Entry<K,V> firstEntry

### lastEntry

    protected LinkedListMultimap.Entry<K,V> lastEntry

### length

    protected int length

### numberOfEntriesForKey

    protected final Map<K,AtomicInteger> numberOfEntriesForKey

### firstEntryWithKey

    protected final Map<K,LinkedListMultimap.Entry<K,V>> firstEntryWithKey

### lastEntryWithKey

    protected final Map<K,LinkedListMultimap.Entry<K,V>> lastEntryWithKey

Constructor Detail

### LinkedListMultimap

    protected LinkedListMultimap()

Method Detail

### create

    public static <K,V> LinkedListMultimap<K,V> create()

  Creates a new, empty `LinkedListMultimap` with the default initial capacity.

  Type Parameters:
    `K` - the key type
    `V` - the value type
  Returns:
    the new linked-list multimap; never null

### clear

    public void clear()

  Remove all key-value pairs from this multimap.

  Specified by:
    `clear` in interface `Multimap<K,V>`
  See Also:
    `Multimap.clear()`

### size

    public int size()

  Return the number of key-value pairs in this multimap.

  Specified by:
    `size` in interface `Multimap<K,V>`
  Returns:
    the size of this multimap.
  See Also:
    `Multimap.size()`

### isEmpty

    public boolean isEmpty()

  Specified by:
    `isEmpty` in interface `Multimap<K,V>`
  See Also:
    `Multimap.isEmpty()`

### containsKey

    public boolean containsKey(K key)

  Determine whether this multimap associates any values with the supplied key.

  Specified by:
    `containsKey` in interface `Multimap<K,V>`
  Parameters:
    `key` - the key
  Returns:
    `true` if there is at least one value associated with the supplied key, or `false` otherwise
  See Also:
    `Multimap.containsKey(java.lang.Object)`

### containsEntry

    public boolean containsEntry(Object key,
                                 Object value)

  Determine whether this multimap contains the supplied key-value pair.

  Specified by:
    `containsEntry` in interface `Multimap<K,V>`
  Parameters:
    `key` - the key
    `value` - the value
  Returns:
    `true` if this multimap contains an entry with the supplied key and value, or `false` otherwise
  See Also:
    `Multimap.containsEntry(java.lang.Object, java.lang.Object)`

### containsValue

    public boolean containsValue(Object value)

  Determine whether this multimap associates at least one key with the supplied value.

  Specified by:
    `containsValue` in interface `Multimap<K,V>`
  Parameters:
    `value` - the value
  Returns:
    `true` if there is at least one key associated with the supplied value, or `false` otherwise
  See Also:
    `Multimap.containsValue(java.lang.Object)`

### get

    public List<V> get(K key)

  Get the collection of values that are associated with the supplied key.

  Changes to the returned collection will update the values that this multimap associates with the key.

  Specified by:
    `get` in interface `ListMultimap<K,V>`
  Specified by:
    `get` in interface `Multimap<K,V>`
  Parameters:
    `key` - the key
  Returns:
    the collection of values, or an empty collection if the supplied key was not associated with any values
  See Also:
    `ListMultimap.get(java.lang.Object)`

### put

    public boolean put(K key,
                       V value)

  Associate the supplied value with the given key, returning true if the size of this multimap was increased.

  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.

  Specified by:
    `put` in interface `Multimap<K,V>`
  Parameters:
    `key` - the key
    `value` - the value
  Returns:
    `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 duplicates
  See Also:
    `Multimap.put(java.lang.Object, java.lang.Object)`

### remove

    public boolean remove(K key,
                          V value)

  Remove the supplied key-value pair from this multi-map.

  Specified by:
    `remove` in interface `Multimap<K,V>`
  Parameters:
    `key` - the key
    `value` - the value
  Returns:
    `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 pair
  See Also:
    `Multimap.remove(java.lang.Object, java.lang.Object)`

### removeAll

    public Collection<V> removeAll(K key)

  Remove all of the key-value pairs that use the supplied key, returning the collection of values. The resulting collection may be modifiable, but changing it will have no effect on this multimap.

  Specified by:
    `removeAll` in interface `Multimap<K,V>`
  Parameters:
    `key` - the key
  Returns:
    the collection of values that were removed, or an empty collection if there were none; never null
  See Also:
    `Multimap.removeAll(java.lang.Object)`

### entries

    public Collection<Map.Entry<K,V>> entries()

  Return a collection of all key-value pairs. Changes to the returned collection will update the underlying multimap, and vice versa. The entries collection does not support the `add` or `addAll` operations.

  Specified by:
    `entries` in interface `Multimap<K,V>`
  Returns:
    the collection of map entries consisting of key-value pairs; never null but possibly empty
  See Also:
    `Multimap.entries()`

### keySet

    public Set<K> keySet()

  Return the set of keys in this multimap.

  Specified by:
    `keySet` in interface `Multimap<K,V>`
  Returns:
    the set of keys; never null but possible empty
  See Also:
    `Multimap.keySet()`

### values

    public Collection<V> values()

  Return a collection of all values in this multimap. Changes to the returned collection will update the underlying multimap, and vice versa.

  Specified by:
    `values` in interface `Multimap<K,V>`
  Returns:
    the collection of values, which may include the same value multiple times if it occurs in multiple mappings; never null but possibly empty
  See Also:
    `Multimap.values()`

### asMap

    public Map<K,Collection<V>> asMap()

  Return a map view that associates each key with the corresponding values in the multimap. Changes to the returned map, such as element removal, will update the underlying multimap. The map does not support `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)`.

  Specified by:
    `asMap` in interface `Multimap<K,V>`
  Returns:
    a map view from a key to its collection of values
  See Also:
    `Multimap.asMap()`

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `Object`
  See Also:
    `Object.hashCode()`

### equals

    public boolean equals(Object obj)

  Overrides:
    `equals` in class `Object`
  See Also:
    `Object.equals(java.lang.Object)`

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`
  See Also:
    `Object.toString()`

### incrementEntryCountFor

    protected int incrementEntryCountFor(K key)

### decrementEntryCountFor

    protected int decrementEntryCountFor(K key)

### currentCountFor

    protected int currentCountFor(K key)

### addEntryFor

    protected LinkedListMultimap.Entry<K,V> addEntryFor(K key,
                                                        V value)

### insertEntryBefore

    protected LinkedListMultimap.Entry<K,V> insertEntryBefore(K key,
                                                              V value,
                                                              LinkedListMultimap.Entry<K,V> nextEntryWithKey)

### removeEntry

    protected void removeEntry(LinkedListMultimap.Entry<K,V> entry)

### isValid

    protected void isValid(LinkedListMultimap.Entry<K,V> entry)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ModeShape Distribution 3.0.0.Alpha6
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2008-2012 JBoss, a division of Red Hat. All Rights Reserved.