Class FloatMap<V>

All Implemented Interfaces:
ICollection<IMap<Double,V>,IEntry<Double,V>>, IMap<Double,V>, ISortedMap<Double,V>, Iterable<IEntry<Double,V>>, Function<Double,V>

public class FloatMap<V> extends ISortedMap.Mixin<Double,V>
A map which has floating-point keys, built atop IntMap, with which it shares performance characteristics.

Since this is intended foremost as a sorted data structure, it does not allow NaN and treats -0.0 as equivalent to 0.0. Anyone looking for identity-based semantics should use a normal Map instead.

  • Field Details

  • Constructor Details

    • FloatMap

      public FloatMap()
  • Method Details

    • from

      public static <V> FloatMap<V> from(IMap<Number,V> m)
    • from

      public static <V> FloatMap<V> from(Map<Number,V> m)
      Parameters:
      m - a Java map
      Returns:
      a forked copy of the map
    • from

      public static <V> FloatMap<V> from(Collection<Map.Entry<Number,V>> collection)
      Parameters:
      collection - a collection of Map.Entry objects
      Returns:
      an IntMap representing the entries in the collection
    • from

      public static <V> FloatMap<V> from(IList<IEntry<Number,V>> list)
      Parameters:
      list - a list of IEntry objects
      Returns:
      an IntMap representing the entries in the list
    • comparator

      public Comparator<Double> comparator()
    • keyHash

      public ToLongFunction<Double> keyHash()
      Returns:
      the hash function used by the map
    • keyEquality

      public BiPredicate<Double,Double> keyEquality()
      Returns:
      the key equality semantics used by the map
    • contains

      public boolean contains(double key)
    • entries

      public IList<IEntry<Double,V>> entries()
      Returns:
      a list containing all the entries within the map
    • indexOf

      public OptionalLong indexOf(double key)
    • indexOf

      public OptionalLong indexOf(Double key)
      Returns:
      the index of key within the collection, if it's present
    • nth

      public IEntry<Double,V> nth(long idx)
      Returns:
      the element at idx
    • size

      public long size()
      Returns:
      the number of elements in the collection
    • floorIndex

      public OptionalLong floorIndex(double key)
    • inclusiveFloorIndex

      public OptionalLong inclusiveFloorIndex(Double key)
    • ceilIndex

      public OptionalLong ceilIndex(double key)
    • ceilIndex

      public OptionalLong ceilIndex(Double key)
    • slice

      public FloatMap<V> slice(double min, ISortedSet.Bound minBound, double max, ISortedSet.Bound maxBound)
    • slice

      public FloatMap<V> slice(double min, double max)
    • slice

      public FloatMap<V> slice(Double min, Double max)
      Parameters:
      min - the inclusive minimum key value
      max - the exclusive maximum key value
      Returns:
      a map representing all entries within [min, max)
    • merge

      public FloatMap<V> merge(IMap<Double,V> b, BinaryOperator<V> mergeFn)
      Parameters:
      b - another map
      mergeFn - a function which, in the case of key collisions, takes two values and returns the merged result
      Returns:
      a new map representing the merger of the two maps
    • difference

      public FloatMap<V> difference(ISet<Double> keys)
      Returns:
      a new map representing the current map, less the keys in keys
    • intersection

      public FloatMap<V> intersection(ISet<Double> keys)
      Returns:
      a new map representing the current map, but only with the keys in keys
    • union

      public FloatMap<V> union(IMap<Double,V> m)
      Returns:
      a combined map, with the values from m shadowing those in this amp
    • difference

      public FloatMap<V> difference(IMap<Double,?> b)
      Returns:
      a new map representing the current map, less the keys in m
    • intersection

      public FloatMap<V> intersection(IMap<Double,?> b)
      Returns:
      a new map representing the current map, but only with the keys in m
    • put

      public FloatMap<V> put(double key, V value)
      Parameters:
      key - a primitive long key
      value - a value
      Returns:
      an updated FloatMap with value under key
    • put

      public FloatMap<V> put(double key, V value, Object editor)
    • put

      public FloatMap<V> put(double key, V value, BinaryOperator<V> merge)
      Parameters:
      key - a primitive long key
      value - a value
      merge - a function which will be invoked if there is a pre-existing value under key, with the current value as the first argument and new value as the second, to determine the combined result
      Returns:
      an updated map
    • put

      public FloatMap<V> put(double key, V value, BinaryOperator<V> merge, Object editor)
    • put

      public FloatMap<V> put(Double key, V value)
      Returns:
      an updated map with value stored under key
    • put

      public FloatMap<V> put(Double key, V value, BinaryOperator<V> merge)
      Parameters:
      merge - a function which will be invoked if there is a pre-existing value under key, with the current value as the first argument and new value as the second, to determine the combined result
      Returns:
      an updated map with value under key
    • remove

      public FloatMap<V> remove(double key)
      Returns:
      an updated map that does not contain key
    • remove

      public FloatMap<V> remove(double key, Object editor)
    • remove

      public FloatMap<V> remove(Double key)
      Returns:
      an updated map that does not contain key
    • mapValues

      public <U> FloatMap<U> mapValues(BiFunction<Double,V,U> f)
      Type Parameters:
      U - the new type of the values
      Parameters:
      f - a function which transforms the values
      Returns:
      a transformed map which shares the same equality semantics
    • get

      public Optional<V> get(double key)
    • get

      public V get(double key, V defaultValue)
    • get

      public V get(Double key, V defaultValue)
      Returns:
      the value under key, or defaultValue if there is no such key
    • update

      public FloatMap<V> update(Double key, UnaryOperator<V> update)
      Parameters:
      update - a function which takes the existing value, or null if none exists, and returns an updated value.
      Returns:
      an updated map with update(value) under key.
    • update

      public FloatMap<V> update(double key, UnaryOperator<V> update)
    • update

      public FloatMap<V> update(double key, UnaryOperator<V> update, Object editor)
    • split

      public List<FloatMap<V>> split(int parts)
      Description copied from interface: ICollection
      Splits the collection into roughly even pieces, for parallel processing. Depending on the size and contents of the collection, this function may not return exactly parts subsets.
      Parameters:
      parts - the target number of pieces
      Returns:
      a list containing subsets of the collection.
    • isLinear

      public boolean isLinear()
      Returns:
      true, if the collection is linear
    • forked

      public FloatMap<V> forked()
      Description copied from interface: ICollection
      This returns a data structure which is forked, which is equivalent to Clojure's persistent data structures, also sometimes called functional or immutable. This is called "forked" because it means that multiple functions can make divergent changes to the data structure without affecting each other.

      If only a single function or scope uses the data structure, it can be left as a linear data structure, which can have significant performance benefits.

      If the data structure is already forked, it will simply return itself.

      Returns:
      a forked form of the data structure
    • linear

      public FloatMap<V> linear()
      Description copied from interface: ICollection
      This returns a data structure which is linear, or temporarily mutable. The term "linear", as used here, does not completely align with the formal definition of linear types as used in type theory. It is meant to describe the linear dataflow of the method calls, and as a converse to "forked" data structures.

      If ICollection.forked() is called on a linear collection, all references to that linear collection should be discarded.

      If the data structure is already linear, it will simply return itself.

      Returns:
      a linear form of this data structure
    • clone

      public FloatMap<V> clone()
      Specified by:
      clone in interface ICollection<IMap<Double,V>,IEntry<Double,V>>
      Overrides:
      clone in class ISortedMap.Mixin<Double,V>
      Returns:
      a cloned copy of the collection
    • equals

      public boolean equals(IMap<Double,V> o, BiPredicate<V,V> valEquals)
      Parameters:
      o - another map
      valEquals - a predicate which checks value equalities
      Returns:
      true, if the maps are equivalent
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class IMap.Mixin<Double,V>