Package org.ojalgo.array
Class NumberList<N extends Comparable<N>>
java.lang.Object
org.ojalgo.array.NumberList<N>
- All Implemented Interfaces:
Iterable<N>
,Collection<N>
,List<N>
,RandomAccess
,SequencedCollection<N>
,Access1D<N>
,Access1D.Visitable<N>
,Mutate1D
,Mutate1D.Mixable<N>
,Structure1D
public final class NumberList<N extends Comparable<N>>
extends Object
implements List<N>, RandomAccess, Access1D<N>, Access1D.Visitable<N>, Mutate1D, Mutate1D.Mixable<N>
Think of this as an
ArrayList
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 ClassesModifier and TypeClassDescriptionstatic final class
NumberList.ListFactory<N extends Comparable<N>>
Nested classes/interfaces inherited from interface org.ojalgo.structure.Access1D
Access1D.Aggregatable<N extends Comparable<N>>, Access1D.Collectable<N extends Comparable<N>,
R extends Mutate1D>, Access1D.ElementView<N extends Comparable<N>>, Access1D.SelectionView<N extends Comparable<N>>, Access1D.Sliceable<N extends Comparable<N>>, Access1D.Visitable<N extends Comparable<N>> Nested classes/interfaces inherited from interface org.ojalgo.structure.Mutate1D
Mutate1D.Fillable<N extends Comparable<N>>, Mutate1D.Mixable<N extends Comparable<N>>, Mutate1D.Modifiable<N extends Comparable<N>>, Mutate1D.ModifiableReceiver<N extends Comparable<N>>, Mutate1D.Receiver<N extends 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
FieldsModifier and TypeFieldDescriptionprivate long
private final DenseArray.Factory
<N> private final GrowthStrategy
private BasicArray
<N> -
Constructor Summary
ConstructorsConstructorDescriptionNumberList
(DenseArray.Factory<N> denseFactory, GrowthStrategy growthStrategy) NumberList
(DenseArray.Factory<N> denseFactory, GrowthStrategy growthStrategy, BasicArray<N> storage, long actualCount) -
Method Summary
Modifier and TypeMethodDescriptionboolean
add
(double element) boolean
add
(float element) void
boolean
boolean
addAll
(double[] elements) boolean
addAll
(int index, Collection<? extends N> elements) boolean
addAll
(Collection<? extends N> elements) aggregateRange
(long first, long limit, Aggregator aggregator) long
capacity()
The current capacity of the underlying data structure.void
clear()
static <N extends Comparable<N>>
Collector<N, NumberList<N>, NumberList<N>> collector
(DenseArray.Factory<N> arrayFactory) boolean
boolean
containsAll
(Collection<?> c) long
count()
The total number of elements in this structure.double
doubleValue
(int index) double
doubleValue
(long index) private void
static <N extends Comparable<N>>
NumberList.ListFactory<N> factory
(DenseArray.Factory<N> arrayFactory) get
(int index) get
(long index) int
boolean
isEmpty()
iterator()
int
lastIndexOf
(Object object) listIterator
(int index) double
mix
(long index, BinaryFunction<N> mixer, double addend) mix
(long index, BinaryFunction<N> mixer, N addend) remove
(int index) boolean
boolean
removeAll
(Collection<?> c) boolean
retainAll
(Collection<?> onlyKeep) void
set
(int index, double value) void
set
(long index, double value) void
set
(long index, float value) void
set
(long index, Comparable<?> value) int
size()
The total number of elements in this structure.subList
(int fromIndex, int toIndex) Object[]
toArray()
<T> T[]
toArray
(T[] array) 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
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.List
addFirst, addLast, equals, getFirst, getLast, hashCode, removeFirst, removeLast, replaceAll, reversed, sort, spliterator
-
Field Details
-
myActualCount
private long myActualCount -
myDenseFactory
-
myGrowthStrategy
-
myStorage
-
-
Constructor Details
-
NumberList
NumberList(DenseArray.Factory<N> denseFactory, GrowthStrategy growthStrategy) -
NumberList
NumberList(DenseArray.Factory<N> denseFactory, GrowthStrategy growthStrategy, BasicArray<N> storage, long actualCount)
-
-
Method Details
-
collector
public static <N extends Comparable<N>> Collector<N,NumberList<N>, collectorNumberList<N>> (DenseArray.Factory<N> arrayFactory) -
factory
public static <N extends Comparable<N>> NumberList.ListFactory<N> factory(DenseArray.Factory<N> arrayFactory) -
add
public boolean add(double element) -
add
public boolean add(float element) -
add
- Specified by:
add
in interfaceList<N extends Comparable<N>>
-
add
- Specified by:
add
in interfaceCollection<N extends Comparable<N>>
- Specified by:
add
in interfaceList<N extends Comparable<N>>
-
addAll
- Specified by:
addAll
in interfaceCollection<N extends Comparable<N>>
- Specified by:
addAll
in interfaceList<N extends Comparable<N>>
-
addAll
public boolean addAll(double[] elements) -
addAll
- Specified by:
addAll
in interfaceList<N extends Comparable<N>>
-
aggregateRange
-
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()- Specified by:
clear
in interfaceCollection<N extends Comparable<N>>
- Specified by:
clear
in interfaceList<N extends Comparable<N>>
-
contains
- Specified by:
contains
in interfaceCollection<N extends Comparable<N>>
- Specified by:
contains
in interfaceList<N extends Comparable<N>>
-
containsAll
- Specified by:
containsAll
in interfaceCollection<N extends Comparable<N>>
- Specified by:
containsAll
in interfaceList<N extends Comparable<N>>
-
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 Comparable<N>>
-
doubleValue
public double doubleValue(long index) - Specified by:
doubleValue
in interfaceAccess1D<N extends Comparable<N>>
-
get
- Specified by:
get
in interfaceList<N extends Comparable<N>>
-
get
- Specified by:
get
in interfaceAccess1D<N extends Comparable<N>>
-
indexOf
- Specified by:
indexOf
in interfaceList<N extends Comparable<N>>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection<N extends Comparable<N>>
- Specified by:
isEmpty
in interfaceList<N extends Comparable<N>>
-
iterator
- Specified by:
iterator
in interfaceCollection<N extends Comparable<N>>
- Specified by:
iterator
in interfaceIterable<N extends Comparable<N>>
- Specified by:
iterator
in interfaceList<N extends Comparable<N>>
-
lastIndexOf
- Specified by:
lastIndexOf
in interfaceList<N extends Comparable<N>>
-
listIterator
- Specified by:
listIterator
in interfaceList<N extends Comparable<N>>
-
listIterator
- Specified by:
listIterator
in interfaceList<N extends Comparable<N>>
-
mix
- Specified by:
mix
in interfaceMutate1D.Mixable<N extends Comparable<N>>
- Returns:
- The new/mixed value
-
mix
- Specified by:
mix
in interfaceMutate1D.Mixable<N extends Comparable<N>>
-
remove
- Specified by:
remove
in interfaceList<N extends Comparable<N>>
-
remove
- Specified by:
remove
in interfaceCollection<N extends Comparable<N>>
- Specified by:
remove
in interfaceList<N extends Comparable<N>>
-
removeAll
- Specified by:
removeAll
in interfaceCollection<N extends Comparable<N>>
- Specified by:
removeAll
in interfaceList<N extends Comparable<N>>
-
retainAll
- Specified by:
retainAll
in interfaceCollection<N extends Comparable<N>>
- Specified by:
retainAll
in interfaceList<N extends Comparable<N>>
-
set
public void set(int index, double value) -
set
- Specified by:
set
in interfaceList<N extends Comparable<N>>
-
set
-
set
public void set(long index, double value) -
set
public void set(long index, float value) -
size
public int size()Description copied from interface:Structure1D
The total number of elements in this structure.- Specified by:
size
in interfaceCollection<N extends Comparable<N>>
- Specified by:
size
in interfaceList<N extends Comparable<N>>
- Specified by:
size
in interfaceStructure1D
-
subList
- Specified by:
subList
in interfaceList<N extends Comparable<N>>
-
toArray
- Specified by:
toArray
in interfaceCollection<N extends Comparable<N>>
- Specified by:
toArray
in interfaceList<N extends Comparable<N>>
-
toArray
public <T> T[] toArray(T[] array) - Specified by:
toArray
in interfaceCollection<N extends Comparable<N>>
- Specified by:
toArray
in interfaceList<N extends Comparable<N>>
-
toString
-
visitOne
- Specified by:
visitOne
in interfaceAccess1D.Visitable<N extends Comparable<N>>
-
ensureCapacity
private void ensureCapacity()
-