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 classNumberList.ListFactory<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 Mutate1D
Mutate1D.Fillable<N>, Mutate1D.Mixable<N>, Mutate1D.Modifiable<N>, Mutate1D.ModifiableReceiver<N>, Mutate1D.Receiver<N>, Mutate1D.SortableNested 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 longprivate final DenseArray.Factory<N, ?> private final GrowthStrategyprivate 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 TypeMethodDescriptionbooleanadd(double element) booleanadd(float element) voidbooleanbooleanaddAll(double[] elements) booleanaddAll(int index, Collection<? extends N> elements) booleanaddAll(Collection<? extends N> elements) aggregateRange(long first, long limit, Aggregator aggregator) longcapacity()The current capacity of the underlying data structure.voidclear()static <N extends Comparable<N>>
Collector<N, NumberList<N>, NumberList<N>> collector(DenseArray.Factory<N, ?> arrayFactory) booleanbooleancontainsAll(Collection<?> c) longcount()The total number of elements in this structure.doubledoubleValue(int index) doubledoubleValue(long index) private voidstatic <N extends Comparable<N>>
NumberList.ListFactory<N> factory(DenseArray.Factory<N, ?> arrayFactory) get(int index) get(long index) intbooleanisEmpty()iterator()intlastIndexOf(Object object) listIterator(int index) doublemix(long index, BinaryFunction<N> mixer, double addend) mix(long index, BinaryFunction<N> mixer, N addend) remove(int index) booleanbooleanremoveAll(Collection<?> c) booleanretainAll(Collection<?> onlyKeep) voidset(int index, double value) voidset(long index, double value) voidset(long index, float value) voidset(long index, Comparable<?> value) intsize()The total number of elements in this structure.subList(int fromIndex, int toIndex) Object[]toArray()<T> T[]toArray(T[] array) toString()voidvisitOne(long index, VoidFunction<N> visitor) 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, nonzeros, select, shortValue, shortValue, supplyTo, toList, toRawCopy1DMethods inherited from interface Access1D.Visitable
visitAll, visitRangeMethods inherited from interface Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface 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>, NumberList<N>> collector(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
-
add
- Specified by:
addin interfaceCollection<N extends Comparable<N>>- Specified by:
addin interfaceList<N extends Comparable<N>>
-
addAll
- Specified by:
addAllin interfaceCollection<N extends Comparable<N>>- Specified by:
addAllin interfaceList<N extends Comparable<N>>
-
addAll
public boolean addAll(double[] elements) -
addAll
- Specified by:
addAllin 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:
clearin interfaceCollection<N extends Comparable<N>>- Specified by:
clearin interfaceList<N extends Comparable<N>>
-
contains
- Specified by:
containsin interfaceCollection<N extends Comparable<N>>- Specified by:
containsin interfaceList<N extends Comparable<N>>
-
containsAll
- Specified by:
containsAllin interfaceCollection<N extends Comparable<N>>- Specified by:
containsAllin interfaceList<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 index) - Specified by:
doubleValuein interfaceAccess1D<N extends Comparable<N>>
-
doubleValue
public double doubleValue(long index) - Specified by:
doubleValuein interfaceAccess1D<N extends Comparable<N>>
-
get
-
get
-
indexOf
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<N extends Comparable<N>>- Specified by:
isEmptyin interfaceList<N extends Comparable<N>>
-
iterator
- Specified by:
iteratorin interfaceCollection<N extends Comparable<N>>- Specified by:
iteratorin interfaceIterable<N extends Comparable<N>>- Specified by:
iteratorin interfaceList<N extends Comparable<N>>
-
lastIndexOf
- Specified by:
lastIndexOfin interfaceList<N extends Comparable<N>>
-
listIterator
- Specified by:
listIteratorin interfaceList<N extends Comparable<N>>
-
listIterator
- Specified by:
listIteratorin interfaceList<N extends Comparable<N>>
-
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>>
-
remove
-
remove
- Specified by:
removein interfaceCollection<N extends Comparable<N>>- Specified by:
removein interfaceList<N extends Comparable<N>>
-
removeAll
- Specified by:
removeAllin interfaceCollection<N extends Comparable<N>>- Specified by:
removeAllin interfaceList<N extends Comparable<N>>
-
retainAll
- Specified by:
retainAllin interfaceCollection<N extends Comparable<N>>- Specified by:
retainAllin interfaceList<N extends Comparable<N>>
-
set
-
set
-
set
-
set
-
set
-
size
public int size()Description copied from interface:Structure1DThe total number of elements in this structure.- Specified by:
sizein interfaceCollection<N extends Comparable<N>>- Specified by:
sizein interfaceList<N extends Comparable<N>>- Specified by:
sizein interfaceStructure1D
-
subList
- Specified by:
subListin interfaceList<N extends Comparable<N>>
-
toArray
- Specified by:
toArrayin interfaceCollection<N extends Comparable<N>>- Specified by:
toArrayin interfaceList<N extends Comparable<N>>
-
toArray
public <T> T[] toArray(T[] array) - Specified by:
toArrayin interfaceCollection<N extends Comparable<N>>- Specified by:
toArrayin interfaceList<N extends Comparable<N>>
-
toString
-
visitOne
- Specified by:
visitOnein interfaceAccess1D.Visitable<N extends Comparable<N>>
-
ensureCapacity
private void ensureCapacity()
-