- java.lang.Object
-
- org.ojalgo.array.BasicArray<N>
-
- org.ojalgo.array.SegmentedArray<N>
-
- All Implemented Interfaces:
Access1D<N>,Access1D.Aggregatable<N>,Access1D.Collectable<N,Mutate1D>,Access1D.Visitable<N>,Mutate1D,Mutate1D.Fillable<N>,Mutate1D.Modifiable<N>,Structure1D
final class SegmentedArray<N extends java.lang.Comparable<N>> extends BasicArray<N>
An array implemented as a sequence of segments that together make up the data structure. Any
BasicArraysubclass can be used for segments. ABasicArray.Factoryis used to create sparse segments (they're not guaranteed to actually be sparse) and aDenseArray.Factoryis used to create dense segments (guaranteed to be dense).
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.ojalgo.array.BasicArray
BasicArray.BaseFactory<N extends java.lang.Comparable<N>,A extends BasicArray<N>>, BasicArray.Factory<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 intmyIndexBitsprivate longmyIndexMaskprivate BasicArray.BaseFactory<N,?>mySegmentFactoryprivate BasicArray<N>[]mySegmentsprivate longmySegmentSizeAll segments except the last one are assumed to (must) be of equal length.
-
Constructor Summary
Constructors Constructor Description SegmentedArray(BasicArray<N>[] segments, BasicArray.BaseFactory<N,?> segmentFactory)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, double addend)voidadd(long index, double addend)voidadd(long index, float addend)voidadd(long index, java.lang.Comparable<?> addend)longcount()The total number of elements in this structure.doubledoubleValue(int index)doubledoubleValue(long index)protected voidexchange(long firstA, long firstB, long step, long count)protected voidfill(long first, long limit, long step, N value)protected voidfill(long first, long limit, long step, NullaryFunction<?> supplier)voidfillAll(N value)voidfillAll(NullaryFunction<?> supplier)voidfillRange(long first, long limit, N value)voidfillRange(long first, long limit, NullaryFunction<?> supplier)Nget(long index)(package private) SegmentedArray<N>grow()Will either grow the last segment to be the same size as all the others, or add another segment (with the same size).protected voidmodify(long first, long limit, long step, BinaryFunction<N> function, Access1D<N> right)protected voidmodify(long first, long limit, long step, UnaryFunction<N> function)protected voidmodify(long first, long limit, long step, Access1D<N> left, BinaryFunction<N> function)voidmodifyOne(long index, UnaryFunction<N> modifier)(package private) static <N extends java.lang.Comparable<N>>
SegmentedArray<N>newInstance(BasicArray.BaseFactory<N,?> segmentFactory, long... structure)voidreset()Reset this mutable structure to some standard (all zeros) initial state.voidset(int index, double value)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.protected voidvisit(long first, long limit, long step, VoidFunction<N> visitor)voidvisitOne(long index, VoidFunction<N> visitor)-
Methods inherited from class org.ojalgo.array.BasicArray
aggregateRange, equals, factory, getMathType, hashCode, indexOfLargest, indexOfLargest, isPrimitive, modifyAll, modifyMatching, modifyMatching, modifyRange, supplyTo, toString, visitAll, visitRange, wrapInArray1D, wrapInArray2D, wrapInArrayAnyD
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, 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.Aggregatable
aggregateAll
-
Methods inherited from interface org.ojalgo.structure.Access1D.Collectable
collect
-
Methods inherited from interface org.ojalgo.structure.Mutate1D
set, set, set, set, set, set, set, set, set
-
Methods inherited from interface org.ojalgo.structure.Mutate1D.Fillable
fillCompatible, fillMatching, fillMatching, fillMatching
-
-
-
-
Field Detail
-
myIndexBits
private final int myIndexBits
-
myIndexMask
private final long myIndexMask
-
mySegmentFactory
private final BasicArray.BaseFactory<N extends java.lang.Comparable<N>,?> mySegmentFactory
-
mySegments
private final BasicArray<N extends java.lang.Comparable<N>>[] mySegments
-
mySegmentSize
private final long mySegmentSize
All segments except the last one are assumed to (must) be of equal length. The last segment cannot be longer than the others.
-
-
Constructor Detail
-
SegmentedArray
SegmentedArray(BasicArray<N>[] segments, BasicArray.BaseFactory<N,?> segmentFactory)
-
-
Method Detail
-
newInstance
static <N extends java.lang.Comparable<N>> SegmentedArray<N> newInstance(BasicArray.BaseFactory<N,?> segmentFactory, long... structure)
-
add
public void add(int index, double addend)
-
add
public void add(long index, java.lang.Comparable<?> addend)
-
add
public void add(long index, double addend)
-
add
public void add(long index, float addend)
-
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.
-
doubleValue
public double doubleValue(int index)
-
doubleValue
public double doubleValue(long index)
-
fillAll
public void fillAll(N value)
-
fillAll
public void fillAll(NullaryFunction<?> supplier)
-
fillRange
public void fillRange(long first, long limit, N value)
-
fillRange
public void fillRange(long first, long limit, NullaryFunction<?> supplier)
-
get
public N get(long index)
-
modifyOne
public void modifyOne(long index, UnaryFunction<N> modifier)
-
reset
public void reset()
Description copied from interface:Mutate1DReset this mutable structure to some standard (all zeros) initial state. It must still be usuable after this call, and the structure/size/shape must not change.
-
set
public void set(int index, double value)
-
set
public void set(long index, java.lang.Comparable<?> value)
-
set
public void set(long index, double value)
-
set
public void set(long index, float value)
-
size
public int size()
Description copied from interface:Structure1DThe total number of elements in this structure.
-
visitOne
public void visitOne(long index, VoidFunction<N> visitor)
-
exchange
protected void exchange(long firstA, long firstB, long step, long count)- Overrides:
exchangein classBasicArray<N extends java.lang.Comparable<N>>
-
fill
protected void fill(long first, long limit, long step, N value)- Overrides:
fillin classBasicArray<N extends java.lang.Comparable<N>>
-
fill
protected void fill(long first, long limit, long step, NullaryFunction<?> supplier)- Overrides:
fillin classBasicArray<N extends java.lang.Comparable<N>>
-
modify
protected void modify(long first, long limit, long step, Access1D<N> left, BinaryFunction<N> function)- Overrides:
modifyin classBasicArray<N extends java.lang.Comparable<N>>
-
modify
protected void modify(long first, long limit, long step, BinaryFunction<N> function, Access1D<N> right)- Overrides:
modifyin classBasicArray<N extends java.lang.Comparable<N>>
-
modify
protected void modify(long first, long limit, long step, UnaryFunction<N> function)- Overrides:
modifyin classBasicArray<N extends java.lang.Comparable<N>>
-
visit
protected void visit(long first, long limit, long step, VoidFunction<N> visitor)- Overrides:
visitin classBasicArray<N extends java.lang.Comparable<N>>
-
grow
SegmentedArray<N> grow()
Will either grow the last segment to be the same size as all the others, or add another segment (with the same size). The returned (could be the same) instance is guaranteed to have a last segment of the same size as the others and at least one more "space" in that segment.
-
-