public class ListMap<TKey extends java.lang.Comparable<TKey>,TValue> extends java.lang.Object implements IListMap<TKey,TValue>
Constructor and Description |
---|
ListMap()
Default constructor.
|
ListMap(java.lang.Class<?> genericTypeParameterKey,
java.lang.Class<?> genericTypeParameterValue)
Constructor for initializing with the key/value generic type parameters
|
ListMap(int initialSize)
Initializes the list-map with an initial size.
|
ListMap(int initialSize,
java.lang.Class<?> genericTypeParameterKey,
java.lang.Class<?> genericTypeParameterValue)
Constructor initializes with an initial collection size and the key/value generic type parameters.
|
ListMap(java.util.Map<? extends TKey,? extends TValue> map)
Constructor initializes from another map
|
ListMap(java.util.Map<? extends TKey,? extends TValue> map,
java.lang.Class<?> genericTypeParameterKey,
java.lang.Class<?> genericTypeParameterValue)
Constructor initializes from another map and the list-map's key/value generic type parameters
|
ListMap(ReifiedMap<TKey,TValue> map)
Constructor initializes with another reified map
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(KeyValuePair<? extends TKey,? extends TValue> kvp)
Adds an item to the collection.
|
boolean |
add(TKey key,
TValue value)
Adds an item to the collection.
|
void |
clear()
Clears the collection.
|
boolean |
contains(TKey key)
Returns true if the given key is contained in the collection.
|
TValue |
get(TKey key)
Returns the key's value if it exists, otherwise throws KeyNotFoundException.
|
TValue |
getAt(int index)
Returns the key's value if the position exists.
|
java.lang.Class<?> |
getGenericTypeParameterKey()
Returns the TKey generic type parameter's class.
|
java.lang.Class<?> |
getGenericTypeParameterValue()
Returns the TValue generic type parameter's class.
|
java.lang.Iterable<TKey> |
getKeys()
Puts all keys in a list and returns them.
|
java.lang.Iterable<TValue> |
getValues()
Puts all keys in a list and returns them.
|
int |
indexOf(TKey key)
Returns the index of the given key, if it is contained in the collection.
|
java.util.Iterator<KeyValuePair<TKey,TValue>> |
iterator()
Returns an iterator of the collection.
|
boolean |
remove(TKey key)
Removes an item from the collection.
|
void |
removeAt(int index)
Removes an item from the collection.
|
boolean |
replace(TKey key,
TValue newValue)
Replaces a key's value with the specified new value.
|
void |
replaceAt(int index,
TValue newValue)
Sets a value at the specified index.
|
int |
size()
Returns the collection size.
|
public ListMap()
SuperTypeTokenException
- When called without using anonymous class semantics.public ListMap(java.lang.Class<?> genericTypeParameterKey, java.lang.Class<?> genericTypeParameterValue)
java.lang.NullPointerException
- When a generic type parameter is null.public ListMap(int initialSize)
java.lang.IllegalArgumentException
- When the buffer size is non positive.SuperTypeTokenException
- When called without using anonymous class semantics.public ListMap(int initialSize, java.lang.Class<?> genericTypeParameterKey, java.lang.Class<?> genericTypeParameterValue)
java.lang.IllegalArgumentException
- When the buffer size is non positive.java.lang.NullPointerException
- When a generic type parameter is null.public ListMap(ReifiedMap<TKey,TValue> map)
java.lang.NullPointerException
- When the argument is null.public ListMap(java.util.Map<? extends TKey,? extends TValue> map)
SuperTypeTokenException
- When called without using anonymous class semantics.java.lang.NullPointerException
- When the argument is null.public ListMap(java.util.Map<? extends TKey,? extends TValue> map, java.lang.Class<?> genericTypeParameterKey, java.lang.Class<?> genericTypeParameterValue)
java.lang.NullPointerException
- When an argument is null.public boolean add(TKey key, TValue value)
public boolean add(KeyValuePair<? extends TKey,? extends TValue> kvp)
public void clear()
public boolean contains(TKey key)
public TValue get(TKey key)
public TValue getAt(int index)
public java.lang.Iterable<TKey> getKeys()
public java.lang.Iterable<TValue> getValues()
public java.lang.Class<?> getGenericTypeParameterKey()
getGenericTypeParameterKey
in interface ReifiedMap<TKey extends java.lang.Comparable<TKey>,TValue>
public java.lang.Class<?> getGenericTypeParameterValue()
getGenericTypeParameterValue
in interface ReifiedMap<TKey extends java.lang.Comparable<TKey>,TValue>
public int indexOf(TKey key)
public java.util.Iterator<KeyValuePair<TKey,TValue>> iterator()
iterator
in interface java.lang.Iterable<KeyValuePair<TKey extends java.lang.Comparable<TKey>,TValue>>
public boolean remove(TKey key)
public void removeAt(int index)
public boolean replace(TKey key, TValue newValue)
public void replaceAt(int index, TValue newValue)