public interface IMap<K,V> extends ICollection<IMap<K,V>,IEntry<K,V>>, Function<K,V>
Modifier and Type | Interface and Description |
---|---|
static interface |
IMap.Durable<K,V> |
static class |
IMap.Mixin<K,V> |
Modifier and Type | Method and Description |
---|---|
default V |
apply(K k) |
default boolean |
contains(K key) |
default boolean |
containsAll(IMap<K,?> map) |
default boolean |
containsAll(ISet<K> set) |
default boolean |
containsAny(IMap<K,?> map) |
default boolean |
containsAny(ISet<K> set) |
default IDiffMap<K,V> |
diff() |
default IMap<K,V> |
difference(IMap<K,?> m) |
default IMap<K,V> |
difference(ISet<K> keys) |
default IList<IEntry<K,V>> |
entries() |
default boolean |
equals(IMap<K,V> m,
BiPredicate<V,V> equals) |
default IMap<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.
|
default Optional<V> |
get(K key) |
default V |
get(K key,
V defaultValue) |
default V |
getOrCreate(K key,
Supplier<V> f) |
default Iterator<IEntry.WithHash<K,V>> |
hashSortedEntries() |
OptionalLong |
indexOf(K key) |
default IMap<K,V> |
intersection(IMap<K,?> m) |
default IMap<K,V> |
intersection(ISet<K> keys) |
default boolean |
isLinear() |
default Iterator<IEntry<K,V>> |
iterator(long startIndex) |
BiPredicate<K,K> |
keyEquality() |
ToLongFunction<K> |
keyHash() |
default ISet<K> |
keys() |
default IMap<K,V> |
linear()
This returns a data structure which is linear, or temporarily mutable.
|
default <U> IMap<K,U> |
mapValues(BiFunction<K,V,U> f) |
default IMap<K,V> |
merge(IMap<K,V> b,
BinaryOperator<V> mergeFn) |
default IMap<K,V> |
put(K key,
V value) |
default IMap<K,V> |
put(K key,
V value,
BinaryOperator<V> merge) |
default IMap<K,V> |
remove(K key) |
default IMap.Durable<K,V> |
save(IDurableEncoding encoding,
Path directory) |
default IMap<K,V> |
sliceIndices(long startIndex,
long endIndex) |
default IList<? extends IMap<K,V>> |
split(int parts)
Splits the collection into roughly even pieces, for parallel processing.
|
default Spliterator<IEntry<K,V>> |
spliterator() |
default Stream<IEntry<K,V>> |
stream() |
default Map<K,V> |
toMap() |
default IMap<K,V> |
union(IMap<K,V> m) |
default IMap<K,V> |
update(K key,
UnaryOperator<V> update) |
default IList<V> |
values() |
ToLongFunction<K> keyHash()
BiPredicate<K,K> keyEquality()
default V get(K key, V defaultValue)
key
, or defaultValue
if there is no such keydefault Optional<V> get(K key)
Optional
containing the value under key
, or nothing if the value is null
or
is not contained within the map.default V getOrCreate(K key, Supplier<V> f)
key
, or one generated by f
if there is no such keydefault boolean contains(K key)
key
is in the map, false otherwisedefault IList<IEntry<K,V>> entries()
OptionalLong indexOf(K key)
key
within the collection, if it's presentdefault <U> IMap<K,U> mapValues(BiFunction<K,V,U> f)
U
- the new type of the valuesf
- a function which transforms the valuesdefault boolean containsAll(ISet<K> set)
set
default boolean containsAll(IMap<K,?> map)
map
default boolean containsAny(ISet<K> set)
set
default boolean containsAny(IMap<K,?> map)
map
default boolean isLinear()
default Map<K,V> toMap()
UnsupportedOperationException
on writesdefault Iterator<IEntry.WithHash<K,V>> hashSortedEntries()
default Spliterator<IEntry<K,V>> spliterator()
spliterator
in interface Iterable<IEntry<K,V>>
default IMap<K,V> merge(IMap<K,V> b, BinaryOperator<V> mergeFn)
b
- another mapmergeFn
- a function which, in the case of key collisions, takes two values and returns the merged resultdefault IMap<K,V> difference(ISet<K> keys)
keys
default IMap<K,V> intersection(ISet<K> keys)
keys
default IMap<K,V> union(IMap<K,V> m)
m
shadowing those in this ampdefault IMap<K,V> difference(IMap<K,?> m)
m
default IMap<K,V> intersection(IMap<K,?> m)
m
default IMap<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
default IMap<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
.default IMap<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.
default IMap<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.
default IList<? extends IMap<K,V>> split(int parts)
ICollection
parts
subsets.default boolean equals(IMap<K,V> m, BiPredicate<V,V> equals)
m
- another mapequals
- a predicate which checks value equalitiesdefault V apply(K k)
apply
in interface Function<K,V>
IllegalArgumentException
- if no such key is inside the mapdefault IMap.Durable<K,V> save(IDurableEncoding encoding, Path directory)