- java.lang.Object
-
- org.ojalgo.array.LongToNumberMap<N>
-
- All Implemented Interfaces:
java.util.Map<java.lang.Long,N>,java.util.SortedMap<java.lang.Long,N>,Access1D<N>,Mutate1D.Mixable<N>,Structure1D
public final class LongToNumberMap<N extends java.lang.Comparable<N>> extends java.lang.Object implements java.util.SortedMap<java.lang.Long,N>, Access1D<N>, Mutate1D.Mixable<N>
ASortedMapwith primitive valued long keys andComparablevalues (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 purposeMapimplementation (usage with high frequency of randomly ordered put and remove operations) it is not very efficient.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLongToNumberMap.MapFactory<N extends java.lang.Comparable<N>>-
Nested classes/interfaces inherited from interface org.ojalgo.structure.Access1D
Access1D.Aggregatable<N extends java.lang.Comparable<N>>, Access1D.Collectable<N extends java.lang.Comparable<N>,R extends Mutate1D>, Access1D.ElementView<N extends java.lang.Comparable<N>>, Access1D.SelectionView<N extends java.lang.Comparable<N>>, Access1D.Sliceable<N extends java.lang.Comparable<N>>, Access1D.Visitable<N extends java.lang.Comparable<N>>
-
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K extends java.lang.Object,V extends java.lang.Object>
-
Nested classes/interfaces inherited from interface org.ojalgo.structure.Structure1D
Structure1D.BasicMapper<T>, Structure1D.IndexMapper<T>, Structure1D.IntIndex, Structure1D.Logical<S extends Structure1D,B extends Structure1D.Logical<S,B>>, Structure1D.LongIndex, Structure1D.LoopCallback
-
-
Field Summary
Fields Modifier and Type Field Description private PlainArray.Factory<N,?>myDenseFactoryprivate GrowthStrategymyGrowthStrategyprivate SparseArray<N>myStorage
-
Constructor Summary
Constructors Constructor Description LongToNumberMap(PlainArray.Factory<N,?> denseFactory, GrowthStrategy growthStrategy)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description longcapacity()The current capacity of the underlying data structure.voidclear()java.util.Comparator<? super java.lang.Long>comparator()booleancontainsKey(long key)booleancontainsKey(java.lang.Object key)booleancontainsValue(double value)booleancontainsValue(java.lang.Object value)longcount()The total number of elements in this structure.doubledoubleValue(int key)doubledoubleValue(long key)java.util.Set<java.util.Map.Entry<java.lang.Long,N>>entrySet()static <N extends java.lang.Comparable<N>>
LongToNumberMap.MapFactory<N>factory(PlainArray.Factory<N,?> denseFactory)java.lang.LongfirstKey()Nget(long key)Nget(java.lang.Object key)(package private) SparseArray<N>getStorage()LongToNumberMap<N>headMap(long toKey)LongToNumberMap<N>headMap(java.lang.Long toKey)booleanisEmpty()java.util.Set<java.lang.Long>keySet()java.lang.LonglastKey()doublemix(long key, BinaryFunction<N> mixer, double addend)Nmix(long key, BinaryFunction<N> mixer, N addend)SparseArray.NonzeroView<N>nonzeros()Similar toAccess1D.elements()but avoids elements that are structurally known to be zero.doubleput(long key, double value)Nput(long key, N value)Nput(java.lang.Long key, N value)voidputAll(java.util.Map<? extends java.lang.Long,? extends N> m)voidputAll(LongToNumberMap<N> m)Nremove(long key)Nremove(java.lang.Object key)intsize()The total number of elements in this structure.LongToNumberMap<N>subMap(long fromKey, long toKey)LongToNumberMap<N>subMap(java.lang.Long fromKey, java.lang.Long toKey)LongToNumberMap<N>tailMap(long fromKey)LongToNumberMap<N>tailMap(java.lang.Long fromKey)java.lang.StringtoString()NumberList<N>values()Access1D<N>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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.ojalgo.structure.Access1D
asCollectable1D, asKeyed1D, asList, axpy, byteValue, byteValue, dot, elements, floatValue, floatValue, intValue, intValue, longValue, longValue, select, shortValue, shortValue, supplyTo, toList, toRawCopy1D
-
-
-
-
Field Detail
-
myDenseFactory
private final PlainArray.Factory<N extends java.lang.Comparable<N>,?> myDenseFactory
-
myGrowthStrategy
private final GrowthStrategy myGrowthStrategy
-
myStorage
private final SparseArray<N extends java.lang.Comparable<N>> myStorage
-
-
Constructor Detail
-
LongToNumberMap
LongToNumberMap(PlainArray.Factory<N,?> denseFactory, GrowthStrategy growthStrategy)
-
-
Method Detail
-
factory
public static <N extends java.lang.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
public void clear()
-
comparator
public java.util.Comparator<? super java.lang.Long> comparator()
-
containsKey
public boolean containsKey(long key)
-
containsKey
public boolean containsKey(java.lang.Object key)
-
containsValue
public boolean containsValue(double value)
-
containsValue
public boolean containsValue(java.lang.Object value)
-
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 java.lang.Comparable<N>>
-
doubleValue
public double doubleValue(long key)
- Specified by:
doubleValuein interfaceAccess1D<N extends java.lang.Comparable<N>>
-
entrySet
public java.util.Set<java.util.Map.Entry<java.lang.Long,N>> entrySet()
-
firstKey
public java.lang.Long firstKey()
-
get
public N get(long key)
-
get
public N get(java.lang.Object key)
-
headMap
public LongToNumberMap<N> headMap(long toKey)
-
headMap
public LongToNumberMap<N> headMap(java.lang.Long toKey)
-
isEmpty
public boolean isEmpty()
-
keySet
public java.util.Set<java.lang.Long> keySet()
-
lastKey
public java.lang.Long lastKey()
-
mix
public double mix(long key, BinaryFunction<N> mixer, double addend)- Specified by:
mixin interfaceMutate1D.Mixable<N extends java.lang.Comparable<N>>- Returns:
- The new/mixed value
-
mix
public N mix(long key, BinaryFunction<N> mixer, N addend)
- Specified by:
mixin interfaceMutate1D.Mixable<N extends java.lang.Comparable<N>>
-
nonzeros
public SparseArray.NonzeroView<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.
-
put
public double put(long key, double value)
-
putAll
public void putAll(LongToNumberMap<N> m)
-
putAll
public void putAll(java.util.Map<? extends java.lang.Long,? extends N> m)
-
remove
public N remove(long key)
-
remove
public N remove(java.lang.Object key)
-
size
public int size()
Description copied from interface:Structure1DThe total number of elements in this structure.- Specified by:
sizein interfacejava.util.Map<java.lang.Long,N extends java.lang.Comparable<N>>- Specified by:
sizein interfaceStructure1D
-
subMap
public LongToNumberMap<N> subMap(long fromKey, long toKey)
-
subMap
public LongToNumberMap<N> subMap(java.lang.Long fromKey, java.lang.Long toKey)
-
tailMap
public LongToNumberMap<N> tailMap(long fromKey)
-
tailMap
public LongToNumberMap<N> tailMap(java.lang.Long fromKey)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
values
public NumberList<N> values()
-
values
public Access1D<N> 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. Any change in the underlying data structure (this map) will corrupt this method's output.
-
getStorage
SparseArray<N> getStorage()
-
-