Package org.ojalgo.data
Class DataBatch
- java.lang.Object
-
- org.ojalgo.data.DataBatch
-
- All Implemented Interfaces:
Access1D<java.lang.Double>
,Access2D<java.lang.Double>
,Access2D.Collectable<java.lang.Double,Mutate2D.Receiver<java.lang.Double>>
,Structure1D
,Structure2D
public final class DataBatch extends java.lang.Object implements Access2D<java.lang.Double>, Access2D.Collectable<java.lang.Double,Mutate2D.Receiver<java.lang.Double>>
A reusable data batch. Build 2D data structures by adding a set of 1D structures treating then as rows. Use it,reset()
and do it again.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.ojalgo.structure.Access2D
Access2D.Aggregatable<N extends java.lang.Comparable<N>>, Access2D.Collectable<N extends java.lang.Comparable<N>,R extends Mutate2D>, Access2D.ColumnView<N extends java.lang.Comparable<N>>, Access2D.ElementView<N extends java.lang.Comparable<N>>, Access2D.RowView<N extends java.lang.Comparable<N>>, Access2D.SelectionView<N extends java.lang.Comparable<N>>, Access2D.Sliceable<N extends java.lang.Comparable<N>>, Access2D.Visitable<N extends java.lang.Comparable<N>>
-
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
-
Nested classes/interfaces inherited from interface org.ojalgo.structure.Structure2D
Structure2D.IntRowColumn, Structure2D.Logical<S extends Structure2D,B extends Structure2D.Logical<S,B>>, Structure2D.LongRowColumn, Structure2D.ReducibleTo1D<R extends Structure1D>, Structure2D.Reshapable, Structure2D.RowColumnKey<R,C>, Structure2D.RowColumnMapper<R,C>
-
-
Field Summary
Fields Modifier and Type Field Description private int
myCursor
private Mutate2D.ModifiableReceiver<java.lang.Double>
myData
-
Constructor Summary
Constructors Constructor Description DataBatch(Mutate2D.ModifiableReceiver<java.lang.Double> data)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addRow(Access1D<java.lang.Double> row)
void
addRows(java.util.Collection<? extends Access1D<java.lang.Double>> rows)
void
addRowWithSingleUnit(int unitIndex)
long
countColumns()
Assumes all rows are of equal length and will only check the first.long
countRows()
Only need to implement if the structure may contain more than Integer.MAX_VALUE elements.double
doubleValue(int row, int col)
Extracts one element of this matrix as a double.static DataBatch
from(Factory2D<? extends Mutate2D.ModifiableReceiver<java.lang.Double>> factory, int batchSize, int dataNodes)
With the batch size/capacity specified.java.lang.Double
get(long row, long col)
int
getColDim()
int
getRowDim()
boolean
isFull()
int
remaining()
Remaining capacity / batch entries / number of rows.void
reset()
void
supplyTo(Mutate2D.Receiver<java.lang.Double> receiver)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.ojalgo.structure.Access1D
asCollectable1D, asKeyed1D, axpy, dot, select, supplyTo, toRawCopy1D
-
Methods inherited from interface org.ojalgo.structure.Access2D
asCollectable2D, asKeyed2D, byteValue, byteValue, byteValue, byteValue, columns, columns, columns, doubleValue, doubleValue, doubleValue, elements, floatValue, floatValue, floatValue, floatValue, get, intValue, intValue, intValue, intValue, longValue, longValue, longValue, longValue, nonzeros, rows, rows, rows, select, select, shortValue, shortValue, shortValue, shortValue, toRawCopy2D
-
Methods inherited from interface org.ojalgo.structure.Access2D.Collectable
collect
-
Methods inherited from interface org.ojalgo.structure.Structure2D
count, firstInColumn, firstInRow, getMaxDim, getMinDim, isEmpty, isFat, isScalar, isSquare, isTall, isVector, limitOfColumn, limitOfRow, size
-
-
-
-
Field Detail
-
myCursor
private int myCursor
-
myData
private final Mutate2D.ModifiableReceiver<java.lang.Double> myData
-
-
Constructor Detail
-
DataBatch
DataBatch(Mutate2D.ModifiableReceiver<java.lang.Double> data)
-
-
Method Detail
-
from
public static DataBatch from(Factory2D<? extends Mutate2D.ModifiableReceiver<java.lang.Double>> factory, int batchSize, int dataNodes)
With the batch size/capacity specified. The returned instance will throw an exception if too many rows are added to it.
-
addRow
public void addRow(Access1D<java.lang.Double> row)
-
addRows
public void addRows(java.util.Collection<? extends Access1D<java.lang.Double>> rows)
-
addRowWithSingleUnit
public void addRowWithSingleUnit(int unitIndex)
-
countColumns
public long countColumns()
Assumes all rows are of equal length and will only check the first. Returns 0 if there are no rows.- Specified by:
countColumns
in interfaceStructure2D
- Returns:
- The number of columns
- See Also:
Structure2D.countColumns()
-
countRows
public long countRows()
Description copied from interface:Structure2D
Only need to implement if the structure may contain more than Integer.MAX_VALUE elements.- Specified by:
countRows
in interfaceStructure2D
- Returns:
- The number of rows
-
doubleValue
public double doubleValue(int row, int col)
Description copied from interface:Access2D
Extracts one element of this matrix as a double.- Specified by:
doubleValue
in interfaceAccess2D<java.lang.Double>
- Parameters:
row
- A row index.col
- A column index.- Returns:
- One matrix element
-
get
public java.lang.Double get(long row, long col)
-
getColDim
public int getColDim()
- Specified by:
getColDim
in interfaceStructure2D
- Returns:
- The number of columns
-
getRowDim
public int getRowDim()
- Specified by:
getRowDim
in interfaceStructure2D
- Returns:
- The number of rows
-
isFull
public boolean isFull()
-
remaining
public int remaining()
Remaining capacity / batch entries / number of rows.
-
reset
public void reset()
-
supplyTo
public void supplyTo(Mutate2D.Receiver<java.lang.Double> receiver)
- Specified by:
supplyTo
in interfaceAccess2D.Collectable<java.lang.Double,Mutate2D.Receiver<java.lang.Double>>
-
-