Package org.ojalgo.array
Class SegmentedArray<N extends Comparable<N>>
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
An array implemented as a sequence of segments that together make up the data structure. Any
BasicArray
subclass can be used for segments. A BasicArray.Factory
is used to create sparse
segments (they're not guaranteed to actually be sparse) and a DenseArray.Factory
is used to create
dense segments (guaranteed to be dense).
-
Nested Class Summary
Nested classes/interfaces inherited from class org.ojalgo.array.BasicArray
BasicArray.Factory<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 final int
private final long
private final ArrayFactory
<N, ?> private final BasicArray<N>[]
private final long
All segments except the last one are assumed to (must) be of equal length. -
Constructor Summary
ConstructorsConstructorDescriptionSegmentedArray
(long count, int indexBits, ArrayFactory<N, ?> segmentFactory) SegmentedArray
(BasicArray<N>[] segments, ArrayFactory<N, ?> segmentFactory) -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(long index, double addend) void
add
(long index, float addend) void
add
(long index, Comparable<?> addend) long
count()
The total number of elements in this structure.double
doubleValue
(int index) double
doubleValue
(long index) protected void
exchange
(long firstA, long firstB, long step, long count) protected void
protected void
fill
(long first, long limit, long step, NullaryFunction<?> supplier) void
void
fillAll
(NullaryFunction<?> supplier) void
void
fillRange
(long first, long limit, NullaryFunction<?> supplier) get
(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 void
modify
(long first, long limit, long step, BinaryFunction<N> function, Access1D<N> right) protected void
modify
(long first, long limit, long step, UnaryFunction<N> function) protected void
modify
(long first, long limit, long step, Access1D<N> left, BinaryFunction<N> function) void
modifyOne
(long index, UnaryFunction<N> modifier) void
reset()
Reset this mutable structure to some standard (all zeros) initial state.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.protected void
visit
(long first, long limit, long step, VoidFunction<N> visitor) void
visitOne
(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, 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.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
Methods inherited from interface org.ojalgo.structure.Mutate1D.Modifiable
add, add, add, add
-
Field Details
-
myIndexBits
private final int myIndexBits -
myIndexMask
private final long myIndexMask -
mySegmentFactory
-
mySegments
-
mySegmentSize
private final long mySegmentSizeAll segments except the last one are assumed to (must) be of equal length. The last segment cannot be longer than the others.
-
-
Constructor Details
-
SegmentedArray
SegmentedArray(BasicArray<N>[] segments, ArrayFactory<N, ?> segmentFactory) -
SegmentedArray
SegmentedArray(long count, int indexBits, ArrayFactory<N, ?> segmentFactory)
-
-
Method Details
-
add
-
add
public void add(long index, double addend) -
add
public void add(long index, float addend) -
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.
-
doubleValue
public double doubleValue(int index) -
doubleValue
public double doubleValue(long index) -
fillAll
-
fillAll
-
fillRange
-
fillRange
-
get
-
modifyOne
-
reset
public void reset()Description copied from interface:Mutate1D
Reset 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
-
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. -
visitOne
-
exchange
protected void exchange(long firstA, long firstB, long step, long count) - Overrides:
exchange
in classBasicArray<N extends Comparable<N>>
-
fill
- Overrides:
fill
in classBasicArray<N extends Comparable<N>>
-
fill
- Overrides:
fill
in classBasicArray<N extends Comparable<N>>
-
modify
protected void modify(long first, long limit, long step, Access1D<N> left, BinaryFunction<N> function) - Overrides:
modify
in classBasicArray<N extends Comparable<N>>
-
modify
protected void modify(long first, long limit, long step, BinaryFunction<N> function, Access1D<N> right) - Overrides:
modify
in classBasicArray<N extends Comparable<N>>
-
modify
- Overrides:
modify
in classBasicArray<N extends Comparable<N>>
-
visit
- Overrides:
visit
in classBasicArray<N extends 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 segement of the same size as the others and at least one more "space" in that segment.
-