K
- The Class of the key for this AbstractMapToListV
- The Class of the Value for this AbstractMapToListpublic abstract class AbstractMapToList<K,V> extends java.lang.Object implements MapToList<K,V>
Modifier | Constructor and Description |
---|---|
protected |
AbstractMapToList(java.util.Map<K,java.util.List<V>> mtl)
Creates a new AbstractMapToList.
|
Modifier and Type | Method and Description |
---|---|
void |
addAllLists(MapToList<K,V> mtl)
Adds all of the Lists in the given MapToList to this MapToList.
|
void |
addAllToListFor(K key,
java.util.Collection<? extends V> values)
Adds all of the Objects in the given list to the (internal) List for the
given key.
|
void |
addToListFor(K key,
int location,
V valueElement)
Adds the given value to the List for the given key at the given location.
|
void |
addToListFor(K key,
V valueElement)
Adds the given value to the List for the given key.
|
void |
clear()
Clears this AbstractMapToList (removes all keys/list combinations).
|
boolean |
containsAnyInList(K key,
java.util.Collection<V> values)
Returns true if this MapToList contains a List for the given key and that
list contains one or more of the values in the given collection.
|
boolean |
containsInList(K key,
V valueElement)
Returns true if this MapToList contains a List for the given key and that
list contains the given value.
|
boolean |
containsListFor(K key)
Returns true if this MapToList contains a List for the given key.
|
boolean |
equals(java.lang.Object obj)
Returns true if this AbstractMapToList is equal to the given Object
(which must also be another AbstractMapToList).
|
V |
getElementInList(K key,
int index)
Returns a specific element in the list for the given key.
|
protected abstract java.util.Set<K> |
getEmptySet()
Returns an empty Set to be used as a value in the underlying Map.
|
java.util.Set<K> |
getKeySet()
Returns a Set indicating the Keys of this MapToList.
|
java.util.List<V> |
getListFor(K key)
Returns a copy of the List contained in this MapToList for the given key.
|
int |
hashCode()
Returns the consistent-with-equals hashCode for this AbstractMapToList.
|
void |
initializeListFor(K key)
Initializes a List for the given key.
|
boolean |
isEmpty()
Returns true if this MapToList contains no Lists.
|
boolean |
removeFromListFor(K key,
V valueElement)
Removes the given value from the list for the given key.
|
java.util.List<V> |
removeListFor(K key)
Removes the List for the given key.
|
int |
size()
Returns the number of lists contained by this MapToList.
|
int |
sizeOfListFor(K key)
Returns the number of objects in the List for the given key.
|
java.lang.String |
toString() |
public void initializeListFor(K key)
key
- The key for which a List should be initialized in this
MapToList.java.lang.IllegalArgumentException
- if this AbstractMapToList already contains a List for the
given keypublic void addToListFor(K key, V valueElement)
addToListFor
in interface MapToList<K,V>
key
- The key indicating which List the given object should be added
to.valueElement
- The value to be added to the List for the given key.public void addToListFor(K key, int location, V valueElement)
key
- The key indicating which List the given object should be added
tolocation
- The location within the list where the given object should be
addedvalueElement
- The value to be added to the List for the given keypublic void addAllToListFor(K key, java.util.Collection<? extends V> values)
addAllToListFor
in interface MapToList<K,V>
key
- The key indicating which List the objects in the given List
should be added to.values
- A Collection containing the items to be added to the List for
the given key.public void addAllLists(MapToList<K,V> mtl)
addAllLists
in interface MapToList<K,V>
mtl
- The MapToList from which all of the Lists should be importedpublic boolean containsListFor(K key)
containsListFor
in interface MapToList<K,V>
key
- The key being tested.public boolean containsInList(K key, V valueElement)
containsInList
in interface MapToList<K,V>
key
- The key for the List being tested.valueElement
- The value to find in the List for the given key.public boolean containsAnyInList(K key, java.util.Collection<V> values)
key
- The key for the List being tested.values
- The collection of values to find in the List for the given
key.public int sizeOfListFor(K key)
sizeOfListFor
in interface MapToList<K,V>
key
- The key being tested.public java.util.List<V> getListFor(K key)
getListFor
in interface MapToList<K,V>
key
- The key for which a copy of the list should be returned.public boolean removeFromListFor(K key, V valueElement)
removeFromListFor
in interface MapToList<K,V>
key
- The key indicating which List the given object should be
removed fromvalueElement
- The value to be removed from the List for the given keypublic java.util.List<V> removeListFor(K key)
removeListFor
in interface MapToList<K,V>
key
- The key indicating which List the given object should be
removed frompublic boolean isEmpty()
public int size()
public V getElementInList(K key, int index)
getElementInList
in interface MapToList<K,V>
key
- The key used to identify the list from which the specified
value will be returnedindex
- The location in the list (for the given key) of the value to
be returnedjava.lang.IllegalArgumentException
- if the given key does not exist in this AbstractMapToListjava.lang.IndexOutOfBoundsException
- if the index is out of range for the list for the given key
(index is less than zero OR greater than or equal to the size
of the list)public void clear()
public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
public java.util.Set<K> getKeySet()
protected abstract java.util.Set<K> getEmptySet()
public int hashCode()
hashCode
in class java.lang.Object
Object.hashCode()
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
Object.equals(Object)