|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.base.apps.util.ListMap<K,V>
public class ListMap<K,V>
Map of lists, backed by a HashMap by default.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
Map.Entry<K,V> |
| Constructor Summary | |
|---|---|
ListMap()
Constructs an empty ListMap. |
|
ListMap(Map<K,List<V>> delegate)
Constructs a ListMap backed by the given Map. |
|
| Method Summary | |
|---|---|
void |
add(K key,
V item)
Adds the given item to the List mapped to the specified key,
creating the list if it does not already exist. |
void |
add(K key,
V item,
int index)
Inserts at index the given item to the List mapped
to the specified key, creating the list if it does not already exist. |
void |
clear()
|
boolean |
contains(K key,
V item)
Returns true if the given item is
contained in the list mapped to the
specified key, return false if the no list is mapped. |
boolean |
contains(V item)
Returns true if the given item is
contained in any of the mapped lists. |
boolean |
containsKey(Object key)
|
boolean |
containsValue(Object value)
|
int |
count()
Fetches the total number of items in all mapped lists. |
Set<Map.Entry<K,List<V>>> |
entrySet()
|
V |
get(K key,
int index)
Fetches an item at the given position from the List mapped to the
specified key, if such a list exists. |
List<V> |
get(Object key)
|
protected Map<K,List<V>> |
getDelegate()
|
boolean |
isEmpty()
|
boolean |
isEmpty(K key)
Returns true if the list mapped to the specified key is
null or contains zero items. |
Set<K> |
keySet()
|
List<V> |
put(K key,
List<V> value)
|
void |
putAll(Map<? extends K,? extends List<V>> m)
|
V |
remove(K key,
int index)
Removes the item at the given position from the List mapped to
the specified key, if such a list exists. |
boolean |
remove(K key,
V item)
Removes the given item from the List mapped to the specified key,
if such a list exists. |
List<V> |
remove(Object key)
|
protected void |
setDelegate(Map<K,List<V>> delegate)
|
int |
size()
|
String |
toString()
|
Collection<List<V>> |
values()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Map |
|---|
equals, hashCode |
| Constructor Detail |
|---|
public ListMap()
ListMap.
public ListMap(Map<K,List<V>> delegate)
ListMap backed by the given Map.
| Method Detail |
|---|
public void add(K key,
V item)
List mapped to the specified key,
creating the list if it does not already exist.
key - The key to which the list is mapped.item - The item to add to the list.
public void add(K key,
V item,
int index)
index the given item to the List mapped
to the specified key, creating the list if it does not already exist.
Out of bound index values will be coerced to be within
the target list's range (based on its size.
key - The key to which the list is mapped.item - The item to add to the list.index - The index at which to add the item.public boolean contains(V item)
true if the given item is
contained in any of the mapped lists.
item - The item to compare against all mapped lists.
true if the item is contained in any list, else false.
public boolean contains(K key,
V item)
true if the given item is
contained in the list mapped to the
specified key, return false if the no list is mapped.
key - The specified key to fetch a list, if one exists.item - The item to compare against the list.
true if the item is contained in the list, else false.
public V get(K key,
int index)
List mapped to the
specified key, if such a list exists.
key - The specified key.index - The item's location.
null.public boolean isEmpty(K key)
true if the list mapped to the specified key is
null or contains zero items.
key - The specified key.
true if the mapped list is null or empty.
public boolean remove(K key,
V item)
List mapped to the specified key,
if such a list exists.
key - The key to which the list is mapped.item - The item to remove from the list.
true if the given item was removed, else false.
public V remove(K key,
int index)
List mapped to
the specified key, if such a list exists.
key - The key to which the list is mapped.index - The item's position in the list.
true if the given item was removed, else false.public int count()
public int size()
size in interface Map<K,List<V>>Map.size()public boolean isEmpty()
isEmpty in interface Map<K,List<V>>Map.isEmpty()public boolean containsKey(Object key)
containsKey in interface Map<K,List<V>>Map.containsKey(java.lang.Object)public boolean containsValue(Object value)
containsValue in interface Map<K,List<V>>Map.containsValue(java.lang.Object)public List<V> get(Object key)
get in interface Map<K,List<V>>Map.get(java.lang.Object)
public List<V> put(K key,
List<V> value)
put in interface Map<K,List<V>>Map.put(java.lang.Object, java.lang.Object)public List<V> remove(Object key)
remove in interface Map<K,List<V>>Map.remove(java.lang.Object)public void putAll(Map<? extends K,? extends List<V>> m)
putAll in interface Map<K,List<V>>Map.putAll(java.util.Map)public void clear()
clear in interface Map<K,List<V>>Map.clear()public Set<K> keySet()
keySet in interface Map<K,List<V>>Map.keySet()public Collection<List<V>> values()
values in interface Map<K,List<V>>Map.values()public Set<Map.Entry<K,List<V>>> entrySet()
entrySet in interface Map<K,List<V>>Map.entrySet()public String toString()
toString in class ObjectObject.toString()protected Map<K,List<V>> getDelegate()
protected void setDelegate(Map<K,List<V>> delegate)
delegate - the delegate to set
|
Please visit Base Apps, hosted on Sourceforge.net. | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||