public class SortedMap<K,V> extends ISortedMap.Mixin<K,V>
ISortedMap.Mixin<K,V>
IMap.Durable<K,V>
Modifier and Type | Field and Description |
---|---|
io.lacuna.bifurcan.nodes.SortedMapNodes.Node<K,V> |
root |
hash
Constructor and Description |
---|
SortedMap() |
SortedMap(Comparator<K> comparator) |
Modifier and Type | Method and Description |
---|---|
OptionalLong |
ceilIndex(K key) |
SortedMap<K,V> |
clone() |
Comparator<K> |
comparator() |
boolean |
contains(K key) |
static <K,V> SortedMap<K,V> |
empty() |
SortedMap<K,V> |
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> |
from(Map<K,V> m) |
V |
get(K key,
V defaultValue) |
OptionalLong |
inclusiveFloorIndex(K key) |
OptionalLong |
indexOf(K key) |
boolean |
isLinear() |
Iterator<IEntry<K,V>> |
iterator() |
BiPredicate<K,K> |
keyEquality() |
ToLongFunction<K> |
keyHash() |
SortedMap<K,V> |
linear()
This returns a data structure which is linear, or temporarily mutable.
|
<U> SortedMap<K,U> |
mapValues(BiFunction<K,V,U> f) |
IEntry<K,V> |
nth(long idx) |
SortedMap<K,V> |
put(K key,
V value) |
SortedMap<K,V> |
put(K key,
V value,
BinaryOperator<V> merge) |
SortedMap<K,V> |
remove(K key) |
long |
size() |
List<SortedMap<K,V>> |
split(int parts)
Splits the collection into roughly even pieces, for parallel processing.
|
SortedMap<K,V> |
update(K key,
UnaryOperator<V> update) |
equals, hashCode, toString
finalize, getClass, notify, notifyAll, wait, wait, wait
ceil, ceil, ceilIndex, difference, difference, diffSorted, first, floor, floor, floorIndex, floorIndex, intersection, keys, last, merge, slice, slice, sliceIndices, union
apply, containsAll, containsAll, containsAny, containsAny, diff, entries, equals, get, getOrCreate, hashSortedEntries, intersection, iterator, save, spliterator, stream, toMap, values
nth
public SortedMap()
public SortedMap(Comparator<K> comparator)
public static <K,V> SortedMap<K,V> empty()
public Comparator<K> comparator()
public OptionalLong inclusiveFloorIndex(K key)
public OptionalLong ceilIndex(K key)
public SortedMap<K,V> update(K key, UnaryOperator<V> update)
update
- a function which takes the existing value, or null
if none exists, and returns an updated
value.update(value)
under key
.public List<SortedMap<K,V>> split(int parts)
ICollection
parts
subsets.parts
- the target number of piecespublic SortedMap<K,V> put(K key, V value, BinaryOperator<V> merge)
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 resultvalue
under key
public V get(K key, V defaultValue)
key
, or defaultValue
if there is no such keypublic boolean contains(K key)
key
is in the map, false otherwisepublic OptionalLong indexOf(K key)
key
within the collection, if it's presentpublic <U> SortedMap<K,U> mapValues(BiFunction<K,V,U> f)
U
- the new type of the valuesf
- a function which transforms the valuespublic long size()
public boolean isLinear()
public SortedMap<K,V> forked()
ICollection
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.
public SortedMap<K,V> linear()
ICollection
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.
public ToLongFunction<K> keyHash()
public BiPredicate<K,K> keyEquality()