Class IndexTrackingTreeMap<V>

java.lang.Object
java.util.AbstractMap<String,V>
java.util.TreeMap<String,V>
org.skriptlang.skript.util.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>

public class IndexTrackingTreeMap<V> extends TreeMap<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:
  • Constructor Details

    • IndexTrackingTreeMap

      public IndexTrackingTreeMap()
    • IndexTrackingTreeMap

      public IndexTrackingTreeMap(Comparator<? super String> comparator)
  • Method Details

    • put

      public V put(String key, V value)
      Specified by:
      put in interface Map<String,V>
      Overrides:
      put in class TreeMap<String,V>
    • add

      public void add(V value)
      Adds the given value under the first available positive integer key.
      Parameters:
      value - the value to add, cannot be null
    • remove

      public V remove(Object key)
      Specified by:
      remove in interface Map<String,V>
      Overrides:
      remove in class TreeMap<String,V>
    • clear

      public void clear()
      Specified by:
      clear in interface Map<String,V>
      Overrides:
      clear in class TreeMap<String,V>
    • 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

      public @UnmodifiableView Collection<String> mapIndices()
      Returns an unmodifiable view of the keys that map to other Map instances.
      Returns:
      a collection of all keys pointing to a map