public class KeyMap<T> extends LinkedHashMap<String,T> implements Iterable<String>
KeyMap
object is used to represent a map of values
keyed using a known string. This also ensures that the keys and
the values added to this hash map can be acquired in an independent
list of values, ensuring that modifications to the map do not have
an impact on the lists provided, and vice versa. The key map can
also be used in a fore each look using the string keys.AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Constructor and Description |
---|
KeyMap()
Constructor for the
KeyMap object. |
Modifier and Type | Method and Description |
---|---|
List<String> |
getKeys()
This is used to produce a
List of the keys in
the map. |
List<T> |
getValues()
This is used to produce a
List of the values in
the map. |
Iterator<String> |
iterator()
This is used to produce an
Iterator of values
that can be used to acquire the contents of the key map within
a for each loop. |
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, removeEldestEntry, replaceAll, values
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
equals, hashCode, toString
finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
compute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
public KeyMap()
KeyMap
object. This creates
a hash map that can expose the keys and values of the map as
an independent List
containing the values. This
can also be used within a for loop for convenience.public Iterator<String> iterator()
Iterator
of values
that can be used to acquire the contents of the key map within
a for each loop. The key map can be modified while it is been
iterated as the iterator is an independent list of values.public List<String> getKeys()
List
of the keys in
the map. The list produced is a copy of the internal keys and
so can be modified and used without affecting this map object.Copyright © 2022. All rights reserved.