public class IntMap<V> extends Object implements ISortedMap<Long,V>, Cloneable
Map, with which it shares the same broad performance
characteristics.
This collection keeps the keys in sorted order, and can thought of as either a map of integers or a sparse vector.
It provides slice(Long, Long), floor(Long), and ceil(Long) methods which
allow for lookups and filtering on its keys.
| Constructor and Description |
|---|
IntMap() |
| Modifier and Type | Method and Description |
|---|---|
IEntry<Long,V> |
ceil(long key) |
IEntry<Long,V> |
ceil(Long key) |
IntMap<V> |
clone() |
Comparator<Long> |
comparator() |
boolean |
contains(long key) |
boolean |
contains(Long key) |
IntMap<V> |
difference(IMap<Long,?> b) |
IntMap<V> |
difference(ISet<Long> keys) |
boolean |
equals(IMap<Long,V> o,
BiPredicate<V,V> valEquals) |
boolean |
equals(Object obj) |
IEntry<Long,V> |
floor(long key) |
IEntry<Long,V> |
floor(Long key) |
IntMap<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 <V> IntMap<V> |
from(Collection<Map.Entry<Number,V>> collection) |
static <V> IntMap<V> |
from(IList<IEntry<Number,V>> list) |
static <V> IntMap<V> |
from(IMap<Number,V> m) |
static <V> IntMap<V> |
from(Map<Number,V> m) |
Optional<V> |
get(long key) |
V |
get(long key,
V defaultValue) |
V |
get(Long key,
V defaultValue) |
int |
hashCode() |
OptionalLong |
indexOf(long key) |
OptionalLong |
indexOf(Long key) |
IntMap<V> |
intersection(IMap<Long,?> b) |
IntMap<V> |
intersection(ISet<Long> keys) |
boolean |
isLinear() |
Iterator<IEntry<Long,V>> |
iterator() |
BiPredicate<Long,Long> |
keyEquality() |
ToLongFunction<Long> |
keyHash() |
IntMap<V> |
linear()
This returns a data structure which is linear, or temporarily mutable.
|
<U> IntMap<U> |
mapValues(BiFunction<Long,V,U> f) |
IntMap<V> |
merge(IMap<Long,V> b,
BinaryOperator<V> mergeFn) |
IEntry<Long,V> |
nth(long idx) |
IntMap<V> |
put(long key,
V value) |
IntMap<V> |
put(Long key,
V value) |
IntMap<V> |
put(long key,
V value,
BinaryOperator<V> merge) |
IntMap<V> |
put(Long key,
V value,
BinaryOperator<V> merge) |
IntMap<V> |
put(long key,
V value,
BinaryOperator<V> merge,
Object editor) |
IntMap<V> |
put(long key,
V value,
Object editor) |
IntMap<V> |
remove(long key) |
IntMap<V> |
remove(Long key) |
IntMap<V> |
remove(long key,
Object editor) |
long |
size() |
IntMap<V> |
slice(long min,
long max) |
IntMap<V> |
slice(Long min,
Long max) |
List<IntMap<V>> |
split(int parts)
Splits the collection into roughly even pieces, for parallel processing.
|
String |
toString() |
IntMap<V> |
union(IMap<Long,V> m) |
IntMap<V> |
update(long key,
UnaryOperator<V> update) |
IntMap<V> |
update(Long key,
UnaryOperator<V> update) |
IntMap<V> |
update(long key,
UnaryOperator<V> update,
Object editor) |
finalize, getClass, notify, notifyAll, wait, wait, waitfirst, lastapply, containsAll, containsAll, containsAny, containsAny, entries, get, getOrCreate, hashSortedEntries, keys, save, spliterator, stream, toMap, valuesnth, savepublic static <V> IntMap<V> from(IMap<Number,V> m)
m - another mappublic static <V> IntMap<V> from(Collection<Map.Entry<Number,V>> collection)
public Comparator<Long> comparator()
comparator in interface ISortedMap<Long,V>public ToLongFunction<Long> keyHash()
public BiPredicate<Long,Long> keyEquality()
keyEquality in interface IMap<Long,V>public IntMap<V> slice(long min, long max)
min - the inclusive minimum key valuemax - the inclusive maximum key value[min, max]public IntMap<V> slice(Long min, Long max)
slice in interface ISortedMap<Long,V>min - the inclusive minimum key valuemax - the inclusive maximum key valuepublic IntMap<V> difference(ISet<Long> keys)
difference in interface IMap<Long,V>difference in interface ISortedMap<Long,V>keyspublic IntMap<V> intersection(ISet<Long> keys)
intersection in interface IMap<Long,V>intersection in interface ISortedMap<Long,V>keyspublic IntMap<V> difference(IMap<Long,?> b)
difference in interface IMap<Long,V>difference in interface ISortedMap<Long,V>mpublic IntMap<V> intersection(IMap<Long,?> b)
intersection in interface IMap<Long,V>mpublic IntMap<V> put(long key, V value)
key - a primitive long keyvalue - a valueIntMap with value under keypublic IntMap<V> put(long key, V value, BinaryOperator<V> merge)
key - a primitive long keyvalue - a valuemerge - 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 resultpublic IntMap<V> put(Long key, V value, BinaryOperator<V> merge)
put in interface IMap<Long,V>put in interface ISortedMap<Long,V>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 keypublic <U> IntMap<U> mapValues(BiFunction<Long,V,U> f)
public IntMap<V> update(Long key, UnaryOperator<V> update)
public IntMap<V> update(long key, UnaryOperator<V> update)
public IntMap<V> update(long key, UnaryOperator<V> update, Object editor)
public boolean contains(long key)
public boolean contains(Long key)
public OptionalLong indexOf(Long key)
public OptionalLong indexOf(long key)
public IEntry<Long,V> floor(long key)
key, or just below it. If key is less than the
minimum value in the map, returns null.public IEntry<Long,V> floor(Long key)
floor in interface ISortedMap<Long,V>key, or just below it. If key is less than the
minimum value in the map, returns null.public IEntry<Long,V> ceil(long key)
key, or just above it. If key is greater than the
maximum value in the map, returns null.public IEntry<Long,V> ceil(Long key)
ceil in interface ISortedMap<Long,V>key, or just above it. If key is greater than the
maximum value in the map, returns null.public long size()
public boolean isLinear()
public IntMap<V> forked()
ICollectionIf 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 IntMap<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 List<IntMap<V>> split(int parts)
ICollectionparts subsets.