Class IndexTrackingTreeMap<V>
- Type Parameters:
V- the type of mapped values
- All Implemented Interfaces:
Serializable, Cloneable, Map<String,V>, NavigableMap<String, V>, SequencedMap<String, V>, SortedMap<String, V>
A
TreeMap that supports automatically assigning the next available
positive integer key, represented as a string.
In addition to arbitrary string keys, this map can be used with
positive integer string keys such as "1", "2", and
"3". The add(Object) method inserts a value using the
next available integer key.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the given value under the first available positive integer key.voidclear()boolean@UnmodifiableView Collection<String> Returns an unmodifiable view of the keys that map to otherMapinstances.intFinds the first available positive integer index that is not currently used as a key in this map.Methods inherited from class TreeMap
ceilingEntry, ceilingKey, clone, comparator, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, descendingKeySet, descendingMap, entrySet, firstEntry, firstKey, floorEntry, floorKey, forEach, get, headMap, headMap, higherEntry, higherKey, keySet, lastEntry, lastKey, lowerEntry, lowerKey, merge, navigableKeySet, pollFirstEntry, pollLastEntry, putAll, putFirst, putIfAbsent, putLast, replace, replace, replaceAll, size, subMap, subMap, tailMap, tailMap, valuesMethods inherited from class AbstractMap
equals, hashCode, isEmpty, toStringMethods inherited from interface NavigableMap
reversedMethods inherited from interface SequencedMap
sequencedEntrySet, sequencedKeySet, sequencedValues
-
Constructor Details
-
IndexTrackingTreeMap
public IndexTrackingTreeMap() -
IndexTrackingTreeMap
-
-
Method Details
-
put
-
add
Adds the given value under the first available positive integer key.- Parameters:
value- the value to add, cannot be null
-
remove
-
clear
-
nextOpenIndex
public int nextOpenIndex()Finds the first available positive integer index that is not currently used as a key in this map.This method inspects tracked numeric keys and returns the smallest missing index, starting at
1.- Returns:
- the next available positive integer index
-
consecutive
public boolean consecutive() -
mapIndices
Returns an unmodifiable view of the keys that map to otherMapinstances.- Returns:
- a collection of all keys pointing to a map
-