ezvcard.util
Class ListMultimap<K,V>

java.lang.Object
  extended by ezvcard.util.ListMultimap<K,V>
Type Parameters:
K - the key
V - the value

public class ListMultimap<K,V>
extends Object

A multimap that uses List objects to store its values.

The internal Map implementation is a LinkedHashMap that uses ArrayList for its values.

Author:
Michael Angstadt

Constructor Summary
ListMultimap()
           
ListMultimap(ListMultimap<K,V> orig)
          Copy constructor.
 
Method Summary
 List<V> get(K key)
          Gets the values associated with the key.
 Map<K,List<V>> getMap()
          Gets the underlying Map object.
 boolean isEmpty()
          Determines if the multimap is empty or not.
 Set<K> keySet()
          Returns all the keys.
 void put(K key, V value)
          Adds a value to the multimap.
 List<V> remove(K key)
          Removes all the values associated with a key
 boolean remove(K key, V value)
          Removes a particular value.
 int size()
          Returns the number of values in the map.
 Collection<V> values()
          Returns all the values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListMultimap

public ListMultimap()

ListMultimap

public ListMultimap(ListMultimap<K,V> orig)
Copy constructor.

Parameters:
orig - the multimap to copy from
Method Detail

put

public void put(K key,
                V value)
Adds a value to the multimap.

Parameters:
key - the key
value - the value

get

public List<V> get(K key)
Gets the values associated with the key.

Parameters:
key - the key
Returns:
the list of values or empty list if the key doesn't exist

remove

public List<V> remove(K key)
Removes all the values associated with a key

Parameters:
key - the key to remove
Returns:
the removed values

remove

public boolean remove(K key,
                      V value)
Removes a particular value.

Parameters:
key - the key
value - the value to remove
Returns:
true if the multimap contained the value, false if not

keySet

public Set<K> keySet()
Returns all the keys.

Returns:
all the keys

values

public Collection<V> values()
Returns all the values.

Returns:
all the values

isEmpty

public boolean isEmpty()
Determines if the multimap is empty or not.

Returns:
true if it's empty, false if not

size

public int size()
Returns the number of values in the map.

Returns:
the number of values

getMap

public Map<K,List<V>> getMap()
Gets the underlying Map object.

Returns:
the underlying Map object


Copyright © 2012-2013. All Rights Reserved.