K - the class of keys for this map.V - the class of values for this map.public final class ListMap<K,V> extends Object implements SortedMap<K,V>
SortedMap with ordering
given by the ordering by which the keys are added.
This is the Map corresponding with ListSet.
Did not use AbstractMap,
e.g. because keySet() shall return more than just a Set.
| Modifier and Type | Class and Description |
|---|---|
private class |
ListMap.Entries
Represents the set of entries of the enclosing map
given by
entrySet(). |
private class |
ListMap.EntriesIterator
Class of iterator of class
ListMap.Entries. |
private class |
ListMap.Entry
Class of entries of the encylosing map.
**** I wonder whether there is no generic implementation
for
Map.Entry. |
private class |
ListMap.Keys
Represents the key set of the enclosing map
given by
keySet(). |
private class |
ListMap.KeysIterator
Class of iterator of class
ListMap.Keys. |
private class |
ListMap.Values
Represents the values collection of the enclosing map
given by
values(). |
private class |
ListMap.ValuesIterator
Class of iterator of class
ListMap.Values. |
private class |
ListMap.XIterator
Common superclass of iterators on key set,
value collection and entries set
providing all methods but
Iterator.next(). |
| Modifier and Type | Field and Description |
|---|---|
private SortedSet<Map.Entry<K,V>> |
entrySet
The set of entries of this map returned by
entrySet(). |
private ListSet<K> |
keys
The set of keys of this
ListMap. |
private SortedSet<K> |
keysSet
The set of keys of this map returned by
keySet(). |
private List<V> |
values
The values of this map.
|
private Collection<V> |
valuesColl
The collection of values of this map returned by
values(). |
| Modifier | Constructor and Description |
|---|---|
|
ListMap()
Creates an empty list map with key set 'ordered as added'
as described by
ListSet.sortedAsAdded(). |
private |
ListMap(ListSet<K> keys,
List<V> values)
Creates a list map defined by the given keys and values
keys and values. |
|
ListMap(Map<K,V> map)
Creates an list map with the same key-value pairs as
map
and with ordering 'as added'. |
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
Comparator<? super K> |
comparator() |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object val) |
SortedSet<Map.Entry<K,V>> |
entrySet() |
boolean |
equals(Object obj) |
K |
firstKey() |
V |
get(Object key) |
int |
hashCode() |
ListMap<K,V> |
headMap(K toKey) |
boolean |
isEmpty() |
SortedSet<K> |
keySet() |
K |
lastKey() |
static void |
main(String[] args) |
private static <K,V> ListSet<K> |
map2keys(Map<K,V> map)
Returns the key set of
map as a ListSet
with ordering 'ordered as added'
as given by ListSet.sortedAsAdded(). |
private static <K,V> List<V> |
map2values(Map<K,V> map)
Returns the value collection of
map as a List
with ordering
given by the iteration on the key set of map. |
V |
put(K key,
V value) |
void |
putAll(Map<? extends K,? extends V> other) |
V |
remove(Object key) |
private boolean |
removeIdx(int idx) |
int |
size() |
(package private) ListMap<K,V> |
subMap(int fromIdx,
int toIdx) |
ListMap<K,V> |
subMap(K fromKey,
K toKey) |
ListMap<K,V> |
tailMap(K fromKey) |
String |
toString() |
Collection<V> |
values() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAllprivate final Collection<V> valuesColl
values().
Note that each ListMap has a single values collection.private final SortedSet<K> keysSet
keySet().
Note that each ListMap has a single key set.private final SortedSet<Map.Entry<K,V>> entrySet
entrySet().
Note that each ListMap has a single entry set.public ListMap()
ListSet.sortedAsAdded().public ListMap(Map<K,V> map)
map
and with ordering 'as added'.
If no additional keys are added, this reflects the ordering
given by iterating through the key set of map.map2keys(Map),
map2values(Map)private ListMap(ListSet<K> keys, List<V> values)
keys and values.
A key and a value correspond iff their index coincides.
Thus keys and values must have the same size.
Note that the entries of keys differ pairwise,
whereas this is not necessary for values.keys - the set of keys as a ListSet.values - the collection of according values as a List
with the same size as keys.IllegalArgumentException - if keys and values differ in size.private static <K,V> ListSet<K> map2keys(Map<K,V> map)
map as a ListSet
with ordering 'ordered as added'
as given by ListSet.sortedAsAdded().
This ordering reflects the ordering
given by the iteration on the key set of map.private static <K,V> List<V> map2values(Map<K,V> map)
map as a List
with ordering
given by the iteration on the key set of map.
Note that there is no documentation ****
that this ordering is the same as the one
of the value collection map#values(). ****public boolean containsKey(Object key)
containsKey in interface Map<K,V>public boolean containsValue(Object val)
containsValue in interface Map<K,V>private boolean removeIdx(int idx)
public Comparator<? super K> comparator()
comparator in interface SortedMap<K,V>public Collection<V> values()
public boolean equals(Object obj)
public int hashCode()
public static void main(String[] args)
Copyright © 2012–2018 Simuline Organization (l2r). All rights reserved.