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>
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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.lacuna.bifurcan.IMap
IMap.Mixin<K,
V> Nested classes/interfaces inherited from interface io.lacuna.bifurcan.ISortedMap
ISortedMap.Mixin<K,
V> -
Field Summary
FieldsFields inherited from class io.lacuna.bifurcan.IMap.Mixin
hash
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionceilIndex
(double key) clone()
boolean
contains
(double key) difference
(IMap<Double, ?> b) difference
(ISet<Double> keys) entries()
boolean
boolean
floorIndex
(double key) forked()
This returns a data structure which is forked, which is equivalent to Clojure's persistent data structures, also sometimes called functional or immutable.static <V> FloatMap
<V> static <V> FloatMap
<V> static <V> FloatMap
<V> from
(Collection<Map.Entry<Number, V>> collection) static <V> FloatMap
<V> get
(double key) indexOf
(double key) intersection
(IMap<Double, ?> b) intersection
(ISet<Double> keys) boolean
isLinear()
keyHash()
linear()
This returns a data structure which is linear, or temporarily mutable.<U> FloatMap
<U> mapValues
(BiFunction<Double, V, U> f) nth
(long idx) put
(double key, V value, BinaryOperator<V> merge) put
(double key, V value, BinaryOperator<V> merge, Object editor) put
(Double key, V value, BinaryOperator<V> merge) remove
(double key) long
size()
slice
(double min, double max) slice
(double min, ISortedSet.Bound minBound, double max, ISortedSet.Bound maxBound) split
(int parts) Splits the collection into roughly even pieces, for parallel processing.update
(double key, UnaryOperator<V> update) update
(double key, UnaryOperator<V> update, Object editor) update
(Double key, UnaryOperator<V> update) Methods inherited from class io.lacuna.bifurcan.IMap.Mixin
hashCode, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.lacuna.bifurcan.ICollection
iterator, nth
Methods inherited from interface io.lacuna.bifurcan.IMap
apply, contains, containsAll, containsAll, containsAny, containsAny, get, getOrCreate, iterator, spliterator, stream, toMap, values
Methods inherited from interface io.lacuna.bifurcan.ISortedMap
ceil, ceil, ceilIndex, first, floor, floor, floorIndex, floorIndex, keys, last, slice, sliceIndices
-
Field Details
-
map
-
-
Constructor Details
-
FloatMap
public FloatMap()
-
-
Method Details
-
from
-
from
-
from
-
from
-
comparator
-
keyHash
- Returns:
- the hash function used by the map
-
keyEquality
- Returns:
- the key equality semantics used by the map
-
contains
public boolean contains(double key) -
entries
-
indexOf
-
indexOf
- Returns:
- the index of
key
within the collection, if it's present
-
nth
-
size
public long size()- Returns:
- the number of elements in the collection
-
floorIndex
-
inclusiveFloorIndex
-
ceilIndex
-
ceilIndex
-
slice
public FloatMap<V> slice(double min, ISortedSet.Bound minBound, double max, ISortedSet.Bound maxBound) -
slice
-
slice
-
merge
-
difference
-
intersection
-
union
-
difference
-
intersection
-
put
-
put
-
put
- Parameters:
key
- a primitivelong
keyvalue
- a valuemerge
- a function which will be invoked if there is a pre-existing value underkey
, with the current value as the first argument and new value as the second, to determine the combined result- Returns:
- an updated map
-
put
-
put
-
put
- Parameters:
merge
- a function which will be invoked if there is a pre-existing value underkey
, 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
underkey
-
remove
-
remove
-
remove
-
mapValues
- 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
-
get
-
get
-
update
- Parameters:
update
- a function which takes the existing value, ornull
if none exists, and returns an updated value.- Returns:
- an updated map with
update(value)
underkey
.
-
update
-
update
-
split
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 exactlyparts
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
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
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
-
equals
-
equals
- Overrides:
equals
in classIMap.Mixin<Double,
V>
-