com.miginfocom.util
Class ListMap

java.lang.Object
  extended by com.miginfocom.util.ListMap
All Implemented Interfaces:
java.util.Map

public class ListMap
extends java.lang.Object
implements java.util.Map

A map that maps keys to a list of objects.


Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Constructor Summary
ListMap(int initialCapacity, float loadFactor, int defaultListSize)
           
 
Method Summary
 void clear()
          Clears ALL lists and makes the map empty.
 boolean containsKey(java.lang.Object key)
           
 boolean containsValue(java.lang.Object value)
          Checks all list for value.
 java.util.Set entrySet()
           
 java.lang.Object get(java.lang.Object key)
          Returns the ArrayList for key or null if none.
 int getIndexInList(java.lang.Object key, java.lang.Object value)
          Returns the index in the list that key point to or -1 if not present in that list.
 java.util.ArrayList getMergedLists(java.lang.Object[] keys)
          Returns an ArrayList with all the values for all list that keys depict.
 boolean isEmpty()
           
 java.util.Set keySet()
           
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          ADDS the value to the list for the key.
 void putAll(java.util.Map map)
          Throws UnsupportedOperationException.
 java.lang.Object remove(java.lang.Object key)
          Removes all objects for the key.
 java.lang.Object remove(java.lang.Object key, java.lang.Object value)
          Removes value from the list that key points to.
 int size()
          Returns the number of keys, not number of objects.
 java.util.Collection values()
          Collects all values for all keys and return them as an ArrayList.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

ListMap

public ListMap(int initialCapacity,
               float loadFactor,
               int defaultListSize)
Method Detail

clear

public void clear()
Clears ALL lists and makes the map empty.

Specified by:
clear in interface java.util.Map

containsKey

public boolean containsKey(java.lang.Object key)
Specified by:
containsKey in interface java.util.Map

containsValue

public boolean containsValue(java.lang.Object value)
Checks all list for value.

Specified by:
containsValue in interface java.util.Map
Parameters:
value - The value to check for.
Returns:
If value is in ANY list.

getIndexInList

public int getIndexInList(java.lang.Object key,
                          java.lang.Object value)
Returns the index in the list that key point to or -1 if not present in that list.

Parameters:
key - The key that may point to a list
value - The value in the list to look for.
Returns:
The index in the list that key point to or -1 if not present in that list.

entrySet

public java.util.Set entrySet()
Specified by:
entrySet in interface java.util.Map

keySet

public java.util.Set keySet()
Specified by:
keySet in interface java.util.Map

get

public java.lang.Object get(java.lang.Object key)
Returns the ArrayList for key or null if none.

Specified by:
get in interface java.util.Map
Parameters:
key - The key
Returns:
The ArrayList for key or null if none.

getMergedLists

public java.util.ArrayList getMergedLists(java.lang.Object[] keys)
Returns an ArrayList with all the values for all list that keys depict.

Parameters:
keys - The keys. not null.
Returns:
An ArrayList with all the values for all list that keys depict. NEver null.

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Map

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
ADDS the value to the list for the key.

Specified by:
put in interface java.util.Map
Parameters:
key - The key
value - The value to add to the list for the key
Returns:
Always null.

putAll

public void putAll(java.util.Map map)
Throws UnsupportedOperationException.

Specified by:
putAll in interface java.util.Map

remove

public java.lang.Object remove(java.lang.Object key)
Removes all objects for the key.

Specified by:
remove in interface java.util.Map
Parameters:
key - The key
Returns:
The ArrayList with all the objects or null if nothing stored for the key.

remove

public java.lang.Object remove(java.lang.Object key,
                               java.lang.Object value)
Removes value from the list that key points to.

Parameters:
key - The key
Returns:
The old removed value or null if not present

size

public int size()
Returns the number of keys, not number of objects.

Specified by:
size in interface java.util.Map
Returns:
The number of keys, not number of objects.

values

public java.util.Collection values()
Collects all values for all keys and return them as an ArrayList.

Specified by:
values in interface java.util.Map
Returns:
All values for all keys and return them as an ArrayList.


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.