Class SortedMap<K,V>
java.lang.Object
io.lacuna.bifurcan.IMap.Mixin<K,V>
io.lacuna.bifurcan.ISortedMap.Mixin<K,V>
io.lacuna.bifurcan.SortedMap<K,V>
- All Implemented Interfaces:
ICollection<IMap<K,
,V>, IEntry<K, V>> IMap<K,
,V> ISortedMap<K,
,V> Iterable<IEntry<K,
,V>> Function<K,
V>
A red-black tree based on Germane 2014.
-
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 TypeMethodDescriptionclone()
boolean
static <K,
V> SortedMap <K, V> empty()
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 <K,
V> SortedMap <K, V> inclusiveFloorIndex
(K key) boolean
isLinear()
iterator()
keyHash()
linear()
This returns a data structure which is linear, or temporarily mutable.mapValues
(BiFunction<K, V, U> f) nth
(long idx) put
(K key, V value, BinaryOperator<V> merge) long
size()
split
(int parts) Splits the collection into roughly even pieces, for parallel processing.update
(K key, UnaryOperator<V> update) Methods inherited from class io.lacuna.bifurcan.IMap.Mixin
equals, hashCode, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.lacuna.bifurcan.ICollection
nth
Methods inherited from interface io.lacuna.bifurcan.IMap
apply, containsAll, containsAll, containsAny, containsAny, entries, equals, get, getOrCreate, intersection, iterator, spliterator, stream, toMap, values
Methods inherited from interface io.lacuna.bifurcan.ISortedMap
ceil, ceil, ceilIndex, difference, difference, first, floor, floor, floorIndex, floorIndex, intersection, keys, last, merge, slice, slice, sliceIndices, union
-
Field Details
-
root
-
-
Constructor Details
-
SortedMap
public SortedMap() -
SortedMap
-
-
Method Details
-
from
-
empty
-
comparator
-
inclusiveFloorIndex
-
ceilIndex
-
update
-
put
-
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.
-
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
-
get
-
contains
- Returns:
- true if
key
is in the map, false otherwise
-
indexOf
- Returns:
- the index of
key
within the collection, if it's present
-
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
-
iterator
-
nth
-
size
public long size()- Returns:
- the number of elements in the collection
-
clone
-
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
-
keyHash
- Returns:
- the hash function used by the map
-
keyEquality
- Returns:
- the key equality semantics used by the map
-