Klasse Object2IntArrayMap<T>

java.lang.Object
java.util.AbstractMap<T,Integer>
speiger.src.collections.objects.maps.abstracts.AbstractObject2IntMap<T>
speiger.src.collections.objects.maps.impl.misc.Object2IntArrayMap<T>
Typparameter:
T - the keyType of elements maintained by this Collection
Alle implementierten Schnittstellen:
ToIntFunction<T>, Map<T,Integer>, ToIntFunction<T>, Object2IntMap<T>, Object2IntOrderedMap<T>

public class Object2IntArrayMap<T> extends AbstractObject2IntMap<T> implements Object2IntOrderedMap<T>
A Very Specific Type Specific implementation of a ArrayMap. This type of map is for very specific use cases that usaully would have lead to Tupled Lists otherwise. It also does not allow duplication (except for array constructors) and checks from last to first. It is not designed to be used as a HashMap replacement due to the poor performance it would cause.
Note:
in this implementation SubMaps do NOT keep track of parent changes fully. For performance reasons it will just have a start/end index and not values Anything within that range will be updated appropiatly a shrink/growth of elements will break SubMaps in some ways. This can be useful but be careful, this implementation does not shrink and only grows.
  • Konstruktordetails

    • Object2IntArrayMap

      public Object2IntArrayMap()
      Default Constructor
    • Object2IntArrayMap

      public Object2IntArrayMap(int minCapacity)
      Constructor that defines the minimum capacity
      Parameter:
      minCapacity - the minimum capacity the HashMap is allowed to be.
      Löst aus:
      IllegalStateException - if the minimum capacity is negative
    • Object2IntArrayMap

      public Object2IntArrayMap(T[] keys, Integer[] values)
      Helper constructor that allow to create a map from boxed values (it will unbox them)
      Parameter:
      keys - the keys that should be put into the map
      values - the values that should be put into the map.
      Löst aus:
      IllegalStateException - if the keys and values do not match in length
    • Object2IntArrayMap

      public Object2IntArrayMap(T[] keys, Integer[] values, int length)
      Helper constructor that allow to create a map from boxed values (it will unbox them) with a custom length
      Parameter:
      keys - the keys that should be put into the map
      values - the values that should be put into the map.
      length - the amount of values that should be pulled from the array
      Löst aus:
      IllegalStateException - if the keys and values do not match in length
    • Object2IntArrayMap

      public Object2IntArrayMap(T[] keys, int[] values)
      Helper constructor that allow to create a map from unboxed values
      Parameter:
      keys - the keys that should be put into the map
      values - the values that should be put into the map.
      Löst aus:
      IllegalStateException - if the keys and values do not match in lenght
    • Object2IntArrayMap

      public Object2IntArrayMap(T[] keys, int[] values, int length)
      Helper constructor that allow to create a map from unboxed values
      Parameter:
      keys - the keys that should be put into the map
      values - the values that should be put into the map.
      length - the amount of values that should be pulled from the array
      Löst aus:
      IllegalStateException - if the keys and values do not match in lenght
    • Object2IntArrayMap

      public Object2IntArrayMap(Map<? extends T,? extends Integer> map)
      A Helper constructor that allows to create a Map with exactly the same values as the provided map.
      Parameter:
      map - the values that should be present in the map
    • Object2IntArrayMap

      public Object2IntArrayMap(Object2IntMap<T> map)
      A Type Specific Helper function that allows to create a new Map with exactly the same values as the provided map.
      Parameter:
      map - the values that should be present in the map
  • Methodendetails

    • put

      public int put(T key, int value)
      Beschreibung aus Schnittstelle kopiert: Object2IntMap
      Type Specific method to reduce boxing/unboxing of values
      Angegeben von:
      put in Schnittstelle Object2IntMap<T>
      Parameter:
      key - the key that should be inserted,
      value - the value that should be inserted
      Gibt zurück:
      the last present value or default return value.
      Siehe auch:
    • putIfAbsent

      public int putIfAbsent(T key, int value)
      Beschreibung aus Schnittstelle kopiert: Object2IntMap
      Type Specific method to reduce boxing/unboxing of values
      Angegeben von:
      putIfAbsent in Schnittstelle Object2IntMap<T>
      Parameter:
      key - the key that should be inserted,
      value - the value that should be inserted
      Gibt zurück:
      the last present value or default return value.
      Siehe auch:
    • addTo

      public int addTo(T key, int value)
      Beschreibung aus Schnittstelle kopiert: Object2IntMap
      A Helper method to add a primitives together. If key is not present then this functions as a put.
      Angegeben von:
      addTo in Schnittstelle Object2IntMap<T>
      Parameter:
      key - the key that should be inserted,
      value - the value that should be inserted / added
      Gibt zurück:
      the last present value or default return value.
    • subFrom

      public int subFrom(T key, int value)
      Beschreibung aus Schnittstelle kopiert: Object2IntMap
      A Helper method to subtract from primitive from each other. If the key is not present it will just return the defaultValue How the implementation works is that it will subtract from the current value (if not present it will do nothing) and fence it to the Object2IntMap.getDefaultReturnValue() If the fence is reached the element will be automaticall removed
      Angegeben von:
      subFrom in Schnittstelle Object2IntMap<T>
      Parameter:
      key - that should be subtract from
      value - that should be subtract
      Gibt zurück:
      the last present or default return value
    • putAndMoveToFirst

      public int putAndMoveToFirst(T key, int value)
      Beschreibung aus Schnittstelle kopiert: Object2IntOrderedMap
      A customized put method that allows you to insert into the first index.
      Angegeben von:
      putAndMoveToFirst in Schnittstelle Object2IntOrderedMap<T>
      Parameter:
      key - the key that should be inserted
      value - the value that should be inserted
      Gibt zurück:
      the previous present or default return value
      Siehe auch:
    • putAndMoveToLast

      public int putAndMoveToLast(T key, int value)
      Beschreibung aus Schnittstelle kopiert: Object2IntOrderedMap
      A customized put method that allows you to insert into the last index. (This may be nessesary depending on the implementation)
      Angegeben von:
      putAndMoveToLast in Schnittstelle Object2IntOrderedMap<T>
      Parameter:
      key - the key that should be inserted
      value - the value that should be inserted
      Gibt zurück:
      the previous present or default return value
      Siehe auch:
    • moveToFirst

      public boolean moveToFirst(T key)
      Beschreibung aus Schnittstelle kopiert: Object2IntOrderedMap
      A specific move method to move a given key/value to the first index.
      Angegeben von:
      moveToFirst in Schnittstelle Object2IntOrderedMap<T>
      Parameter:
      key - that should be moved to the first index
      Gibt zurück:
      true if the value was moved.
    • moveToLast

      public boolean moveToLast(T key)
      Beschreibung aus Schnittstelle kopiert: Object2IntOrderedMap
      A specific move method to move a given key/value to the last index.
      Angegeben von:
      moveToLast in Schnittstelle Object2IntOrderedMap<T>
      Parameter:
      key - that should be moved to the first last
      Gibt zurück:
      true if the value was moved.
    • containsValue

      public boolean containsValue(int value)
      Beschreibung aus Schnittstelle kopiert: Object2IntMap
      Type Specific method to reduce boxing/unboxing of values
      Angegeben von:
      containsValue in Schnittstelle Object2IntMap<T>
      Setzt außer Kraft:
      containsValue in Klasse AbstractObject2IntMap<T>
      Parameter:
      value - element that is searched for
      Gibt zurück:
      if the value is present
    • containsKey

      public boolean containsKey(Object key)
      Angegeben von:
      containsKey in Schnittstelle Map<T,Integer>
      Setzt außer Kraft:
      containsKey in Klasse AbstractObject2IntMap<T>
    • containsValue

      public boolean containsValue(Object value)
      Angegeben von:
      containsValue in Schnittstelle Map<T,Integer>
      Angegeben von:
      containsValue in Schnittstelle Object2IntMap<T>
      Setzt außer Kraft:
      containsValue in Klasse AbstractMap<T,Integer>
      Parameter:
      value - that is searched for.
      Gibt zurück:
      true if found
      Siehe auch:
    • getInt

      public int getInt(T key)
      Beschreibung aus Schnittstelle kopiert: Object2IntMap
      A Type Specific get method to reduce boxing/unboxing
      Angegeben von:
      getInt in Schnittstelle Object2IntMap<T>
      Parameter:
      key - the key that is searched for
      Gibt zurück:
      the searched value or default return value
    • getOrDefault

      public int getOrDefault(Object key, int defaultValue)
      Beschreibung aus Schnittstelle kopiert: Object2IntMap
      A Type Specific getOrDefault method to reduce boxing/unboxing
      Angegeben von:
      getOrDefault in Schnittstelle Object2IntMap<T>
      Parameter:
      key - the key that is searched for
      defaultValue - the value that should be returned if the key is not present
      Gibt zurück:
      the searched value or defaultValue value
    • getAndMoveToFirst

      public int getAndMoveToFirst(T key)
      Beschreibung aus Schnittstelle kopiert: Object2IntOrderedMap
      A Specific get method that allows to move teh given key/value int the first index.
      Angegeben von:
      getAndMoveToFirst in Schnittstelle Object2IntOrderedMap<T>
      Parameter:
      key - that is searched for
      Gibt zurück:
      the given value for the requested key or default return value
    • getAndMoveToLast

      public int getAndMoveToLast(T key)
      Beschreibung aus Schnittstelle kopiert: Object2IntOrderedMap
      A Specific get method that allows to move teh given key/value int the last index.
      Angegeben von:
      getAndMoveToLast in Schnittstelle Object2IntOrderedMap<T>
      Parameter:
      key - that is searched for
      Gibt zurück:
      the given value for the requested key or default return value
    • firstKey

      public T firstKey()
      Beschreibung aus Schnittstelle kopiert: Object2IntOrderedMap
      A method to get the first Key of a Map.
      Angegeben von:
      firstKey in Schnittstelle Object2IntOrderedMap<T>
      Gibt zurück:
      the first key in the map
    • lastKey

      public T lastKey()
      Beschreibung aus Schnittstelle kopiert: Object2IntOrderedMap
      A method to get the last Key of a Map.
      Angegeben von:
      lastKey in Schnittstelle Object2IntOrderedMap<T>
      Gibt zurück:
      the last key in the map
    • firstIntValue

      public int firstIntValue()
      Beschreibung aus Schnittstelle kopiert: Object2IntOrderedMap
      A method to get the first Value of a Map.
      Angegeben von:
      firstIntValue in Schnittstelle Object2IntOrderedMap<T>
      Gibt zurück:
      the first key in the map
    • lastIntValue

      public int lastIntValue()
      Beschreibung aus Schnittstelle kopiert: Object2IntOrderedMap
      A method to get the last Value of a Map.
      Angegeben von:
      lastIntValue in Schnittstelle Object2IntOrderedMap<T>
      Gibt zurück:
      the last key in the map
    • pollFirstKey

      public T pollFirstKey()
      Beschreibung aus Schnittstelle kopiert: Object2IntOrderedMap
      A method to get and remove the first Key of a Map.
      Angegeben von:
      pollFirstKey in Schnittstelle Object2IntOrderedMap<T>
      Gibt zurück:
      the first key in the map
    • pollLastKey

      public T pollLastKey()
      Beschreibung aus Schnittstelle kopiert: Object2IntOrderedMap
      A method to get and remove the last Key of a Map.
      Angegeben von:
      pollLastKey in Schnittstelle Object2IntOrderedMap<T>
      Gibt zurück:
      the last key in the map
    • rem

      public int rem(T key)
      Beschreibung aus Schnittstelle kopiert: Object2IntMap
      Type Specific remove function to reduce boxing/unboxing
      Angegeben von:
      rem in Schnittstelle Object2IntMap<T>
      Parameter:
      key - the element that should be removed
      Gibt zurück:
      the value that was removed or default return value
    • remOrDefault

      public int remOrDefault(T key, int defaultValue)
      Beschreibung aus Schnittstelle kopiert: Object2IntMap
      Type-Specific Remove function with a default return value if wanted.
      Angegeben von:
      remOrDefault in Schnittstelle Object2IntMap<T>
      Parameter:
      key - the element that should be removed
      defaultValue - the value that should be returned if the entry doesn't exist
      Gibt zurück:
      the value that was removed or default value
      Siehe auch:
    • remove

      public boolean remove(T key, int value)
      Beschreibung aus Schnittstelle kopiert: Object2IntMap
      Type Specific remove function to reduce boxing/unboxing
      Angegeben von:
      remove in Schnittstelle Object2IntMap<T>
      Parameter:
      key - the element that should be removed
      value - the expected value that should be found
      Gibt zurück:
      true if the key and value was found and removed
      Siehe auch:
    • remove

      public Integer remove(Object key)
      Angegeben von:
      remove in Schnittstelle Map<T,Integer>
      Angegeben von:
      remove in Schnittstelle Object2IntMap<T>
      Setzt außer Kraft:
      remove in Klasse AbstractObject2IntMap<T>
      Parameter:
      key - the element that should be removed
      Gibt zurück:
      the value that was removed or default return value
      Siehe auch:
    • remove

      public boolean remove(Object key, Object value)
      Angegeben von:
      remove in Schnittstelle Map<T,Integer>
      Angegeben von:
      remove in Schnittstelle Object2IntMap<T>
      Parameter:
      key - the element that should be removed
      value - the expected value that should be found
      Gibt zurück:
      true if the key and value was found and removed
      Siehe auch:
    • forEach

      public void forEach(ObjectIntConsumer<T> action)
      Beschreibung aus Schnittstelle kopiert: Object2IntMap
      Type Specific forEach method to reduce boxing/unboxing
      Angegeben von:
      forEach in Schnittstelle Object2IntMap<T>
      Setzt außer Kraft:
      forEach in Klasse AbstractObject2IntMap<T>
      Parameter:
      action - processor of the values that are iterator over
    • keySet

      public ObjectOrderedSet<T> keySet()
      Angegeben von:
      keySet in Schnittstelle Map<T,Integer>
      Angegeben von:
      keySet in Schnittstelle Object2IntMap<T>
      Angegeben von:
      keySet in Schnittstelle Object2IntOrderedMap<T>
      Setzt außer Kraft:
      keySet in Klasse AbstractObject2IntMap<T>
    • values

      public IntCollection values()
      Angegeben von:
      values in Schnittstelle Map<T,Integer>
      Angegeben von:
      values in Schnittstelle Object2IntMap<T>
      Setzt außer Kraft:
      values in Klasse AbstractObject2IntMap<T>
    • object2IntEntrySet

      public ObjectOrderedSet<Object2IntMap.Entry<T>> object2IntEntrySet()
      Beschreibung aus Schnittstelle kopiert: Object2IntMap
      Type Sensitive EntrySet to reduce boxing/unboxing and optionally Temp Object Allocation.
      Angegeben von:
      object2IntEntrySet in Schnittstelle Object2IntMap<T>
      Angegeben von:
      object2IntEntrySet in Schnittstelle Object2IntOrderedMap<T>
      Gibt zurück:
      a EntrySet of the collection
    • replace

      public boolean replace(T key, int oldValue, int newValue)
      Beschreibung aus Schnittstelle kopiert: Object2IntMap
      A Type Specific replace method to replace an existing value
      Angegeben von:
      replace in Schnittstelle Object2IntMap<T>
      Setzt außer Kraft:
      replace in Klasse AbstractObject2IntMap<T>
      Parameter:
      key - the element that should be searched for
      oldValue - the expected value to be replaced
      newValue - the value to replace the oldValue with.
      Gibt zurück:
      true if the value got replaced
    • replace

      public int replace(T key, int value)
      Beschreibung aus Schnittstelle kopiert: Object2IntMap
      A Type Specific replace method to reduce boxing/unboxing replace an existing value
      Angegeben von:
      replace in Schnittstelle Object2IntMap<T>
      Setzt außer Kraft:
      replace in Klasse AbstractObject2IntMap<T>
      Parameter:
      key - the element that should be searched for
      value - the value to replace with.
      Gibt zurück:
      the present value or default return value
    • computeInt

      public int computeInt(T key, ObjectIntUnaryOperator<T> mappingFunction)
      Beschreibung aus Schnittstelle kopiert: Object2IntMap
      A Type Specific compute method to reduce boxing/unboxing If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null". A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
      Angegeben von:
      computeInt in Schnittstelle Object2IntMap<T>
      Setzt außer Kraft:
      computeInt in Klasse AbstractObject2IntMap<T>
      Parameter:
      key - the key that should be computed
      mappingFunction - the operator that should generate the value
      Gibt zurück:
      the result of the computation
    • computeIntIfAbsent

      public int computeIntIfAbsent(T key, ToIntFunction<T> mappingFunction)
      Beschreibung aus Schnittstelle kopiert: Object2IntMap
      A Type Specific computeIfAbsent method to reduce boxing/unboxing If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null". A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
      Angegeben von:
      computeIntIfAbsent in Schnittstelle Object2IntMap<T>
      Setzt außer Kraft:
      computeIntIfAbsent in Klasse AbstractObject2IntMap<T>
      Parameter:
      key - the key that should be computed
      mappingFunction - the operator that should generate the value if not present
      Gibt zurück:
      the result of the computed value or present value
    • supplyIntIfAbsent

      public int supplyIntIfAbsent(T key, IntSupplier valueProvider)
      Beschreibung aus Schnittstelle kopiert: Object2IntMap
      A Supplier based computeIfAbsent function to fill the most used usecase of this function If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null". A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
      Angegeben von:
      supplyIntIfAbsent in Schnittstelle Object2IntMap<T>
      Setzt außer Kraft:
      supplyIntIfAbsent in Klasse AbstractObject2IntMap<T>
      Parameter:
      key - the key that should be computed
      valueProvider - the value if not present
      Gibt zurück:
      the result of the computed value or present value
    • computeIntIfPresent

      public int computeIntIfPresent(T key, ObjectIntUnaryOperator<T> mappingFunction)
      Beschreibung aus Schnittstelle kopiert: Object2IntMap
      A Type Specific compute method to reduce boxing/unboxing If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null". A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
      Angegeben von:
      computeIntIfPresent in Schnittstelle Object2IntMap<T>
      Setzt außer Kraft:
      computeIntIfPresent in Klasse AbstractObject2IntMap<T>
      Parameter:
      key - the key that should be computed
      mappingFunction - the operator that should generate the value if present
      Gibt zurück:
      the result of the default return value or present value
    • computeIntNonDefault

      public int computeIntNonDefault(T key, ObjectIntUnaryOperator<T> mappingFunction)
      Beschreibung aus Schnittstelle kopiert: Object2IntMap
      A Type Specific compute method to reduce boxing/unboxing If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null". A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
      Angegeben von:
      computeIntNonDefault in Schnittstelle Object2IntMap<T>
      Setzt außer Kraft:
      computeIntNonDefault in Klasse AbstractObject2IntMap<T>
      Parameter:
      key - the key that should be computed
      mappingFunction - the operator that should generate the value
      Gibt zurück:
      the result of the computation
    • computeIntIfAbsentNonDefault

      public int computeIntIfAbsentNonDefault(T key, ToIntFunction<T> mappingFunction)
      Beschreibung aus Schnittstelle kopiert: Object2IntMap
      A Type Specific computeIfAbsent method to reduce boxing/unboxing If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null". A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
      Angegeben von:
      computeIntIfAbsentNonDefault in Schnittstelle Object2IntMap<T>
      Setzt außer Kraft:
      computeIntIfAbsentNonDefault in Klasse AbstractObject2IntMap<T>
      Parameter:
      key - the key that should be computed
      mappingFunction - the operator that should generate the value if not present
      Gibt zurück:
      the result of the computed value or present value
    • supplyIntIfAbsentNonDefault

      public int supplyIntIfAbsentNonDefault(T key, IntSupplier valueProvider)
      Beschreibung aus Schnittstelle kopiert: Object2IntMap
      A Supplier based computeIfAbsent function to fill the most used usecase of this function If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null". A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
      Angegeben von:
      supplyIntIfAbsentNonDefault in Schnittstelle Object2IntMap<T>
      Setzt außer Kraft:
      supplyIntIfAbsentNonDefault in Klasse AbstractObject2IntMap<T>
      Parameter:
      key - the key that should be computed
      valueProvider - the value if not present
      Gibt zurück:
      the result of the computed value or present value
    • computeIntIfPresentNonDefault

      public int computeIntIfPresentNonDefault(T key, ObjectIntUnaryOperator<T> mappingFunction)
      Beschreibung aus Schnittstelle kopiert: Object2IntMap
      A Type Specific compute method to reduce boxing/unboxing If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null". A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
      Angegeben von:
      computeIntIfPresentNonDefault in Schnittstelle Object2IntMap<T>
      Setzt außer Kraft:
      computeIntIfPresentNonDefault in Klasse AbstractObject2IntMap<T>
      Parameter:
      key - the key that should be computed
      mappingFunction - the operator that should generate the value if present
      Gibt zurück:
      the result of the default return value or present value
    • mergeInt

      public int mergeInt(T key, int value, IntIntUnaryOperator mappingFunction)
      Beschreibung aus Schnittstelle kopiert: Object2IntMap
      A Type Specific merge method to reduce boxing/unboxing If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null". A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
      Angegeben von:
      mergeInt in Schnittstelle Object2IntMap<T>
      Setzt außer Kraft:
      mergeInt in Klasse AbstractObject2IntMap<T>
      Parameter:
      key - the key that should be be searched for
      value - the value that should be merged with
      mappingFunction - the operator that should generate the new Value
      Gibt zurück:
      the result of the merge
    • mergeAllInt

      public void mergeAllInt(Object2IntMap<T> m, IntIntUnaryOperator mappingFunction)
      Beschreibung aus Schnittstelle kopiert: Object2IntMap
      A Bulk method for merging Maps. If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null". A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
      Angegeben von:
      mergeAllInt in Schnittstelle Object2IntMap<T>
      Setzt außer Kraft:
      mergeAllInt in Klasse AbstractObject2IntMap<T>
      Parameter:
      m - the entries that should be bulk added
      mappingFunction - the operator that should generate the new Value
    • size

      public int size()
      Angegeben von:
      size in Schnittstelle Map<T,Integer>
      Setzt außer Kraft:
      size in Klasse AbstractMap<T,Integer>
    • clear

      public void clear()
      Angegeben von:
      clear in Schnittstelle Map<T,Integer>
      Setzt außer Kraft:
      clear in Klasse AbstractMap<T,Integer>
    • copy

      public Object2IntArrayMap<T> copy()
      Beschreibung aus Schnittstelle kopiert: Object2IntMap
      A Function that does a shallow clone of the Map itself. This function is more optimized then a copy constructor since the Map does not have to be unsorted/resorted. It can be compared to Cloneable but with less exception risk
      Angegeben von:
      copy in Schnittstelle Object2IntMap<T>
      Angegeben von:
      copy in Schnittstelle Object2IntOrderedMap<T>
      Setzt außer Kraft:
      copy in Klasse AbstractObject2IntMap<T>
      Gibt zurück:
      a Shallow Copy of the Map