- java.lang.Object
-
- org.ojalgo.array.NumberList<N>
-
- All Implemented Interfaces:
java.lang.Iterable<N>,java.util.Collection<N>,java.util.List<N>,java.util.RandomAccess,Access1D<N>,Access1D.Visitable<N>,Mutate1D,Mutate1D.Mixable<N>,Structure1D
public final class NumberList<N extends java.lang.Comparable<N>> extends java.lang.Object implements java.util.List<N>, java.util.RandomAccess, Access1D<N>, Access1D.Visitable<N>, Mutate1D, Mutate1D.Mixable<N>
Think of this as anArrayListthat can only contain numbers, but with a few extra features. Among other things it can be arbitrarily large (using long indices rather than int) and contain primitive double values. And of course it integrates perfectly with everything else in ojAlgo.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classNumberList.ListFactory<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 org.ojalgo.structure.Mutate1D
Mutate1D.Fillable<N extends java.lang.Comparable<N>>, Mutate1D.Mixable<N extends java.lang.Comparable<N>>, Mutate1D.Modifiable<N extends java.lang.Comparable<N>>, Mutate1D.ModifiableReceiver<N extends java.lang.Comparable<N>>, Mutate1D.Receiver<N extends java.lang.Comparable<N>>, Mutate1D.Sortable
-
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 longmyActualCountprivate DenseArray.Factory<N,?>myDenseFactoryprivate GrowthStrategymyGrowthStrategyprivate BasicArray<N>myStorage
-
Constructor Summary
Constructors Constructor Description NumberList(DenseArray.Factory<N,?> denseFactory, GrowthStrategy growthStrategy)NumberList(DenseArray.Factory<N,?> denseFactory, GrowthStrategy growthStrategy, BasicArray<N> storage, long actualCount)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(double element)booleanadd(float element)voidadd(int index, N element)booleanadd(N element)booleanaddAll(double[] elements)booleanaddAll(int index, java.util.Collection<? extends N> elements)booleanaddAll(java.util.Collection<? extends N> elements)NaggregateRange(long first, long limit, Aggregator aggregator)longcapacity()The current capacity of the underlying data structure.voidclear()static <N extends java.lang.Comparable<N>>
java.util.stream.Collector<N,NumberList<N>,NumberList<N>>collector(DenseArray.Factory<N,?> arrayFactory)booleancontains(java.lang.Object object)booleancontainsAll(java.util.Collection<?> c)longcount()The total number of elements in this structure.doubledoubleValue(int index)doubledoubleValue(long index)private voidensureCapacity()static <N extends java.lang.Comparable<N>>
NumberList.ListFactory<N>factory(DenseArray.Factory<N,?> arrayFactory)Nget(int index)Nget(long index)intindexOf(java.lang.Object object)booleanisEmpty()java.util.Iterator<N>iterator()intlastIndexOf(java.lang.Object object)java.util.ListIterator<N>listIterator()java.util.ListIterator<N>listIterator(int index)doublemix(long index, BinaryFunction<N> mixer, double addend)Nmix(long index, BinaryFunction<N> mixer, N addend)Nremove(int index)booleanremove(java.lang.Object o)booleanremoveAll(java.util.Collection<?> c)booleanretainAll(java.util.Collection<?> onlyKeep)voidset(int index, double value)Nset(int index, N element)voidset(long index, double value)voidset(long index, float value)voidset(long index, java.lang.Comparable<?> value)intsize()The total number of elements in this structure.NumberList<N>subList(int fromIndex, int toIndex)java.lang.Object[]toArray()<T> T[]toArray(T[] array)java.lang.StringtoString()voidvisitOne(long index, VoidFunction<N> visitor)-
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, nonzeros, select, shortValue, shortValue, supplyTo, toList, toRawCopy1D
-
Methods inherited from interface org.ojalgo.structure.Access1D.Visitable
visitAll, visitRange
-
-
-
-
Field Detail
-
myActualCount
private long myActualCount
-
myDenseFactory
private final DenseArray.Factory<N extends java.lang.Comparable<N>,?> myDenseFactory
-
myGrowthStrategy
private final GrowthStrategy myGrowthStrategy
-
myStorage
private BasicArray<N extends java.lang.Comparable<N>> myStorage
-
-
Constructor Detail
-
NumberList
NumberList(DenseArray.Factory<N,?> denseFactory, GrowthStrategy growthStrategy)
-
NumberList
NumberList(DenseArray.Factory<N,?> denseFactory, GrowthStrategy growthStrategy, BasicArray<N> storage, long actualCount)
-
-
Method Detail
-
collector
public static <N extends java.lang.Comparable<N>> java.util.stream.Collector<N,NumberList<N>,NumberList<N>> collector(DenseArray.Factory<N,?> arrayFactory)
-
factory
public static <N extends java.lang.Comparable<N>> NumberList.ListFactory<N> factory(DenseArray.Factory<N,?> arrayFactory)
-
add
public boolean add(double element)
-
add
public boolean add(float element)
-
add
public void add(int index, N element)
-
add
public boolean add(N element)
-
addAll
public boolean addAll(java.util.Collection<? extends N> elements)
-
addAll
public boolean addAll(double[] elements)
-
addAll
public boolean addAll(int index, java.util.Collection<? extends N> elements)
-
aggregateRange
public N aggregateRange(long first, long limit, Aggregator aggregator)
-
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 items in the list. When you add items to the list the capacity may have to grow.
-
clear
public void clear()
-
contains
public boolean contains(java.lang.Object object)
-
containsAll
public boolean containsAll(java.util.Collection<?> c)
-
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 index)
- Specified by:
doubleValuein interfaceAccess1D<N extends java.lang.Comparable<N>>
-
doubleValue
public double doubleValue(long index)
- Specified by:
doubleValuein interfaceAccess1D<N extends java.lang.Comparable<N>>
-
get
public N get(int index)
-
get
public N get(long index)
-
indexOf
public int indexOf(java.lang.Object object)
-
isEmpty
public boolean isEmpty()
-
iterator
public java.util.Iterator<N> iterator()
-
lastIndexOf
public int lastIndexOf(java.lang.Object object)
-
listIterator
public java.util.ListIterator<N> listIterator()
-
listIterator
public java.util.ListIterator<N> listIterator(int index)
-
mix
public double mix(long index, 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 index, BinaryFunction<N> mixer, N addend)
- Specified by:
mixin interfaceMutate1D.Mixable<N extends java.lang.Comparable<N>>
-
remove
public N remove(int index)
-
remove
public boolean remove(java.lang.Object o)
-
removeAll
public boolean removeAll(java.util.Collection<?> c)
-
retainAll
public boolean retainAll(java.util.Collection<?> onlyKeep)
-
set
public void set(long index, java.lang.Comparable<?> value)
-
size
public int size()
Description copied from interface:Structure1DThe total number of elements in this structure.
-
subList
public NumberList<N> subList(int fromIndex, int toIndex)
-
toArray
public java.lang.Object[] toArray()
-
toArray
public <T> T[] toArray(T[] array)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
visitOne
public void visitOne(long index, VoidFunction<N> visitor)- Specified by:
visitOnein interfaceAccess1D.Visitable<N extends java.lang.Comparable<N>>
-
ensureCapacity
private void ensureCapacity()
-
-