Class LongToNumberMap<N extends Comparable<N>>
java.lang.Object
org.ojalgo.array.LongToNumberMap<N>
- All Implemented Interfaces:
Map<Long,N>, SequencedMap<Long, N>, SortedMap<Long, N>, Access1D<N>, Mutate1D.Mixable<N>, Structure1D
public final class LongToNumberMap<N extends Comparable<N>>
extends Object
implements SortedMap<Long,N>, Access1D<N>, Mutate1D.Mixable<N>
A
SortedMap with primitive valued long keys and Comparable values (incl. possibly primitive
double values). The main benefits of using this class is its use of primitive keys and values, and how it
integrates with other parts of ojAlgo. As a general purpose Map implementation (usage with high
frequency of randomly ordered put and remove operations) it is not very efficient.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classLongToNumberMap.MapFactory<N extends Comparable<N>>Nested classes/interfaces inherited from interface Access1D
Access1D.Aggregatable<N>, Access1D.Collectable<N,R>, Access1D.ElementView<N>, Access1D.SelectionView<N>, Access1D.Sliceable<N>, Access1D.Visitable<N> Nested classes/interfaces inherited from interface Structure1D
Structure1D.BasicMapper<T>, Structure1D.IndexMapper<T>, Structure1D.IntIndex, Structure1D.Logical<S,B>, Structure1D.LongIndex, Structure1D.LoopCallback -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final PlainArray.Factory<N, ?> private final GrowthStrategyprivate final SparseArray<N> -
Constructor Summary
ConstructorsConstructorDescriptionLongToNumberMap(PlainArray.Factory<N, ?> denseFactory, GrowthStrategy growthStrategy) -
Method Summary
Modifier and TypeMethodDescriptionlongcapacity()The current capacity of the underlying data structure.voidclear()Comparator<? super Long> booleancontainsKey(long key) booleancontainsKey(Object key) booleancontainsValue(double value) booleancontainsValue(Object value) longcount()The total number of elements in this structure.doubledoubleValue(int key) doubledoubleValue(long key) entrySet()static <N extends Comparable<N>>
LongToNumberMap.MapFactory<N> factory(PlainArray.Factory<N, ?> denseFactory) firstKey()get(long key) (package private) SparseArray<N> headMap(long toKey) booleanisEmpty()keySet()lastKey()doublemix(long key, BinaryFunction<N> mixer, double addend) mix(long key, BinaryFunction<N> mixer, N addend) nonzeros()Similar toAccess1D.elements()but avoids elements that are structurally known to be zero.doubleput(long key, double value) voidvoidputAll(LongToNumberMap<N> m) remove(long key) intsize()The total number of elements in this structure.subMap(long fromKey, long toKey) tailMap(long fromKey) toString()values()values(long fromKey, long toKey) Should return the same elements/values as first callingsubMap(Long, Long)and thenvalues()but this method does not create any copies.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Access1D
asCollectable1D, asKeyed1D, asList, axpy, byteValue, byteValue, dot, elements, floatValue, floatValue, intValue, intValue, longValue, longValue, select, shortValue, shortValue, supplyTo, toList, toRawCopy1DMethods inherited from interface Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAllMethods inherited from interface SequencedMap
firstEntry, lastEntry, pollFirstEntry, pollLastEntry, sequencedEntrySet, sequencedKeySet, sequencedValues
-
Field Details
-
myDenseFactory
-
myGrowthStrategy
-
myStorage
-
-
Constructor Details
-
LongToNumberMap
LongToNumberMap(PlainArray.Factory<N, ?> denseFactory, GrowthStrategy growthStrategy)
-
-
Method Details
-
factory
public static <N extends Comparable<N>> LongToNumberMap.MapFactory<N> factory(PlainArray.Factory<N, ?> denseFactory) -
capacity
public long capacity()The current capacity of the underlying data structure. The capacity is always greater than or equal to the current number of entries in the map. When you add entries to the map the capacity may have to grow. -
clear
-
comparator
- Specified by:
comparatorin interfaceSortedMap<Long, N extends Comparable<N>>
-
containsKey
public boolean containsKey(long key) -
containsKey
- Specified by:
containsKeyin interfaceMap<Long, N extends Comparable<N>>
-
containsValue
public boolean containsValue(double value) -
containsValue
- Specified by:
containsValuein interfaceMap<Long, N extends Comparable<N>>
-
count
public long count()Description copied from interface:Structure1DThe total number of elements in this structure.You only need to implement this method if the structure can contain more than Integer.MAX_VALUE elements.
- Specified by:
countin interfaceStructure1D
-
doubleValue
public double doubleValue(int key) - Specified by:
doubleValuein interfaceAccess1D<N extends Comparable<N>>
-
doubleValue
public double doubleValue(long key) - Specified by:
doubleValuein interfaceAccess1D<N extends Comparable<N>>
-
entrySet
-
firstKey
-
get
-
get
-
headMap
-
headMap
-
isEmpty
-
keySet
-
lastKey
-
mix
- Specified by:
mixin interfaceMutate1D.Mixable<N extends Comparable<N>>- Returns:
- The new/mixed value
-
mix
- Specified by:
mixin interfaceMutate1D.Mixable<N extends Comparable<N>>
-
nonzeros
Description copied from interface:Access1DSimilar toAccess1D.elements()but avoids elements that are structurally known to be zero. (That does not eliminate all zero-values from this view.) With an arbitrary (dense) unstructured implementation theAccess1D.nonzeros()andAccess1D.elements()methods do the same thing! Only some specific implementations are able to actually exploit structure/sparsity to view fewer elements.- Specified by:
nonzerosin interfaceAccess1D<N extends Comparable<N>>
-
put
public double put(long key, double value) -
put
-
put
-
putAll
-
putAll
-
remove
-
remove
-
size
public int size()Description copied from interface:Structure1DThe total number of elements in this structure.- Specified by:
sizein interfaceMap<Long, N extends Comparable<N>>- Specified by:
sizein interfaceStructure1D
-
subMap
-
subMap
-
tailMap
-
tailMap
-
toString
-
values
-
values
Should return the same elements/values as first callingsubMap(Long, Long)and thenvalues()but this method does not create any copies. Any change in the underlying data structure (this map) will corrupt this method's output. -
getStorage
SparseArray<N> getStorage()
-