Package org.ojalgo.array
Class NumberList<N extends java.lang.Comparable<N>>
- 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 anArrayList
that 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 class
NumberList.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 long
myActualCount
private DenseArray.Factory<N>
myDenseFactory
private GrowthStrategy
myGrowthStrategy
private 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 boolean
add(double element)
boolean
add(float element)
void
add(int index, N element)
boolean
add(N element)
boolean
addAll(double[] elements)
boolean
addAll(int index, java.util.Collection<? extends N> elements)
boolean
addAll(java.util.Collection<? extends N> elements)
N
aggregateRange(long first, long limit, Aggregator aggregator)
long
capacity()
The current capacity of the underlying data structure.void
clear()
static <N extends java.lang.Comparable<N>>
java.util.stream.Collector<N,NumberList<N>,NumberList<N>>collector(DenseArray.Factory<N> arrayFactory)
boolean
contains(java.lang.Object object)
boolean
containsAll(java.util.Collection<?> c)
long
count()
The total number of elements in this structure.double
doubleValue(int index)
double
doubleValue(long index)
private void
ensureCapacity()
static <N extends java.lang.Comparable<N>>
NumberList.ListFactory<N>factory(DenseArray.Factory<N> arrayFactory)
N
get(int index)
N
get(long index)
int
indexOf(java.lang.Object object)
boolean
isEmpty()
java.util.Iterator<N>
iterator()
int
lastIndexOf(java.lang.Object object)
java.util.ListIterator<N>
listIterator()
java.util.ListIterator<N>
listIterator(int index)
double
mix(long index, BinaryFunction<N> mixer, double addend)
N
mix(long index, BinaryFunction<N> mixer, N addend)
N
remove(int index)
boolean
remove(java.lang.Object o)
boolean
removeAll(java.util.Collection<?> c)
boolean
retainAll(java.util.Collection<?> onlyKeep)
void
set(int index, double value)
N
set(int index, N element)
void
set(long index, double value)
void
set(long index, float value)
void
set(long index, java.lang.Comparable<?> value)
int
size()
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.String
toString()
void
visitOne(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, axpy, byteValue, byteValue, dot, elements, floatValue, floatValue, intValue, intValue, longValue, longValue, nonzeros, select, shortValue, shortValue, supplyTo, 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:Structure1D
The 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:
count
in interfaceStructure1D
-
doubleValue
public double doubleValue(int index)
- Specified by:
doubleValue
in interfaceAccess1D<N extends java.lang.Comparable<N>>
-
doubleValue
public double doubleValue(long index)
- Specified by:
doubleValue
in 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:
mix
in 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:
mix
in 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:Structure1D
The 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:
toString
in classjava.lang.Object
-
visitOne
public void visitOne(long index, VoidFunction<N> visitor)
- Specified by:
visitOne
in interfaceAccess1D.Visitable<N extends java.lang.Comparable<N>>
-
ensureCapacity
private void ensureCapacity()
-
-