@Immutable public final class Long2DoubleSortedArrayMap extends AbstractLong2DoubleSortedMap
An immutable long-to-double map backed by a sorted key array.
AbstractLong2DoubleSortedMap.KeySet, AbstractLong2DoubleSortedMap.KeySetIterator, AbstractLong2DoubleSortedMap.ValuesCollection, AbstractLong2DoubleSortedMap.ValuesIterator
AbstractLong2DoubleMap.BasicEntry
Long2DoubleSortedMap.FastSortedEntrySet
Long2DoubleMap.Entry, Long2DoubleMap.FastEntrySet
defRetValue
Constructor and Description |
---|
Long2DoubleSortedArrayMap(Map<Long,Double> data)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
LongComparator |
comparator() |
boolean |
containsKey(long k) |
static Long2DoubleSortedArrayMap |
create(Long2DoubleMap input)
Create a new long-to-double sorted array map from another map.
|
static Long2DoubleSortedArrayMap |
create(Map<Long,Double> data)
Create a new sorted array map from input data.
|
long |
firstLongKey() |
static Long2DoubleSortedArrayMap |
fromArray(KeyIndex mapping,
double[] values)
Create a map from an array and index mapping.
|
static Long2DoubleSortedArrayMap |
fromArray(KeyIndex mapping,
DoubleList values)
Create a map from an array and index mapping.
|
double |
get(long l) |
long |
getKeyByIndex(int i)
Get a key by its position in the map.
|
double |
getValueByIndex(int i)
Get a value by its position in the map.
|
Long2DoubleSortedMap |
headMap(long l) |
LongSortedArraySet |
keySet() |
long |
lastLongKey() |
Long2DoubleSortedMap.FastSortedEntrySet |
long2DoubleEntrySet() |
int |
size() |
Long2DoubleSortedMap |
subMap(long from,
long to) |
Long2DoubleSortedMap |
subMap(LongSet toKeep)
Return a subset of this map containing only the keys that appear in another set.
|
Long2DoubleSortedMap |
tailMap(long l) |
static Long2DoubleSortedArrayMap |
wrap(SortedKeyIndex keys,
double[] vs)
Create a new long-to-double map backed by a key index and a corresponding value array.
|
static Long2DoubleSortedArrayMap |
wrapUnsorted(long[] keys,
double[] values)
Create a new
MutableSparseVector from unsorted key and value arrays. |
entrySet, firstKey, headMap, lastKey, subMap, tailMap, values
containsValue, containsValue, equals, hashCode, isEmpty, putAll, toString
clear, containsKey, defaultReturnValue, defaultReturnValue, get, put, put, remove, remove
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
containsValue
defaultReturnValue, defaultReturnValue, put, remove
clear, containsKey, get, put, remove
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, equals, forEach, get, getOrDefault, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll
@Deprecated public Long2DoubleSortedArrayMap(Map<Long,Double> data)
Create a new map with existing data.
data
- Use create(Map)
instead, as it can avoid copying maps that are already packed.public static Long2DoubleSortedArrayMap create(Long2DoubleMap input)
Create a new long-to-double sorted array map from another map.
Using this method instead of the constructor allows copies of immutable vectors to be skipped.
input
- The vector to copy.input
.public static Long2DoubleSortedArrayMap wrap(SortedKeyIndex keys, double[] vs)
Create a new long-to-double map backed by a key index and a corresponding value array.
keys
- The keys.vs
- The values (the array is used as-is, it is not copied).public static Long2DoubleSortedArrayMap wrapUnsorted(long[] keys, double[] values)
Create a new MutableSparseVector
from unsorted key and value arrays. The provided arrays will be modified and should not be used by the client after this operation has completed. The key domain of the new MutableSparseVector
will be the same as keys
.
keys
- Array of entry keys. This should be duplicate-free.values
- The values of the vector, in key order.IllegalArgumentException
- if there is a problem with the provided arrays (length mismatch, etc.).public static Long2DoubleSortedArrayMap fromArray(KeyIndex mapping, double[] values)
Create a map from an array and index mapping.
mapping
- The index mapping specifying the keys.values
- The array of values.map
to the values in values
.IllegalArgumentException
- if values
not the same size as idx
.public static Long2DoubleSortedArrayMap fromArray(KeyIndex mapping, DoubleList values)
Create a map from an array and index mapping.
mapping
- The index mapping specifying the keys.values
- The array of values.map
to the values in values
.IllegalArgumentException
- if values
not the same size as idx
.public static Long2DoubleSortedArrayMap create(Map<Long,Double> data)
Create a new sorted array map from input data.
data
- The input data.public Long2DoubleSortedMap.FastSortedEntrySet long2DoubleEntrySet()
public LongSortedArraySet keySet()
keySet
in interface Long2DoubleMap
keySet
in interface Long2DoubleSortedMap
keySet
in interface Map<Long,Double>
keySet
in interface SortedMap<Long,Double>
keySet
in class AbstractLong2DoubleSortedMap
public long getKeyByIndex(int i)
Get a key by its position in the map. Used for optimizing certain operations.
i
- The index.i
.public double getValueByIndex(int i)
Get a value by its position in the map. Used for optimizing certain operations.
i
- The index.i
.public LongComparator comparator()
public Long2DoubleSortedMap subMap(long from, long to)
public Long2DoubleSortedMap subMap(LongSet toKeep)
Return a subset of this map containing only the keys that appear in another set.
toKeep
- The set of keys to keep.keys
.public Long2DoubleSortedMap headMap(long l)
public Long2DoubleSortedMap tailMap(long l)
public long firstLongKey()
public long lastLongKey()
public double get(long l)
public boolean containsKey(long k)
containsKey
in interface Long2DoubleFunction
containsKey
in class AbstractLong2DoubleMap
public int size()