Interface DataDoubleBuffer
- All Superinterfaces:
DataBuffer
Data buffer for double elements.
- Author:
- Daniel Alievsky
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.algart.arrays.DataBuffer
DataBuffer.AccessMode
-
Method Summary
Modifier and TypeMethodDescriptiondouble[]
data()
Returns the Java array which contains the mapped region of the data.force()
Writes all elements in the actual region of theDataBuffer.data()
Java array (fromDataBuffer.fromIndex()
, inclusive, toDataBuffer.toIndex()
, exclusive) back to the underlying data storage (usually AlgART array).map
(long position) Maps this data buffer to the specified position of the underlying data storage (usually AlgART array) for accessing firstDataBuffer.capacity()
elements starting from this position.map
(long position, boolean readData) An analog ofDataBuffer.map(long)
with the only exception, that when readData=false, reading data from the data storage is not guaranteed.map
(long position, long maxCount) Equivalent tomap(position, maxCount, true)
.map
(long position, long maxCount, boolean readData) Maps this data buffer to the specified position of the underlying data storage (usually AlgART array) for accessing first min(maxCount,DataBuffer.capacity()
) elements starting from this position.mapNext()
Maps the next region in the underlying data storage (usually AlgART array).mapNext
(boolean readData) An analog ofDataBuffer.mapNext()
with the only exception, that when readData=false, reading data from the data storage is not guaranteed.
-
Method Details
-
map
Description copied from interface:DataBuffer
Maps this data buffer to the specified position of the underlying data storage (usually AlgART array) for accessing firstDataBuffer.capacity()
elements starting from this position. The fragment of the data storage will be loaded and accessible in theDataBuffer.data()
Java array at the positionsDataBuffer.fromIndex()
..DataBuffer.toIndex()
-1. Equivalent tomap
(DataBuffer.position()
,DataBuffer.capacity()
,true).The passed argument must be in range 0..length, where length is the total number of elements in the underlying data storage (for an AlgART array, its
Array.length()
). The number of actually mapped elements (DataBuffer.count()
) will be equal to min(DataBuffer.capacity()
,length-position).- Specified by:
map
in interfaceDataBuffer
- Parameters:
position
- new mapping position.- Returns:
- a reference to this data buffer.
- See Also:
-
map
Description copied from interface:DataBuffer
An analog ofDataBuffer.map(long)
with the only exception, that when readData=false, reading data from the data storage is not guaranteed. (When readData=true, there is no difference withDataBuffer.map(long)
method.) Equivalent tomap
(DataBuffer.position()
,DataBuffer.capacity()
,readData). The mode readData=false can be useful for optimization inDataBuffer.AccessMode.READ_WRITE
mode, if you are sure that you will fully rewrite all mapped elements and, so, want to save time by avoiding useless reading them.- Specified by:
map
in interfaceDataBuffer
- Parameters:
position
- new mapping position.readData
- if true, all mapped elements will be really loaded from the data storage; if false, there is no such a guarantee.- Returns:
- a reference to this data buffer.
- See Also:
-
mapNext
DataDoubleBuffer mapNext()Description copied from interface:DataBuffer
Maps the next region in the underlying data storage (usually AlgART array). Equivalent tomap
(DataBuffer.position()
+DataBuffer.count()
). In particular, if the buffer is newly created andDataBuffer.map(long)
and mapNext() were never called yet, this method is equivalent tomap
(0).The following loop allows to sequentially map all elements of the underlying data storage:
for (buf.
map
(0); buf.DataBuffer.hasData()
; buf.mapNext()) { // ... (processing elements of buf.DataBuffer.data()
) }- Specified by:
mapNext
in interfaceDataBuffer
- Returns:
- a reference to this data buffer.
- See Also:
-
mapNext
Description copied from interface:DataBuffer
An analog ofDataBuffer.mapNext()
with the only exception, that when readData=false, reading data from the data storage is not guaranteed. (When readData=true, there is no difference withDataBuffer.mapNext()
method.) Equivalent tomap
(DataBuffer.position()
+DataBuffer.count()
, readData). The mode readData=false can be useful for optimization inDataBuffer.AccessMode.READ_WRITE
mode, if you are sure that you will fully rewrite all mapped elements and, so, want to save time by avoiding useless reading them.- Specified by:
mapNext
in interfaceDataBuffer
- Parameters:
readData
- if true, all mapped elements will be really loaded from the data storage; if false, there is no such a guarantee.- Returns:
- a reference to this data buffer.
- See Also:
-
map
Description copied from interface:DataBuffer
Equivalent tomap(position, maxCount, true)
.- Specified by:
map
in interfaceDataBuffer
- Parameters:
position
- new mapping position.maxCount
- this method does not guarantee that the elements after #position+maxCount-1 will be loaded into the buffer.- Returns:
- a reference to this data buffer.
- See Also:
-
map
Description copied from interface:DataBuffer
Maps this data buffer to the specified position of the underlying data storage (usually AlgART array) for accessing first min(maxCount,DataBuffer.capacity()
) elements starting from this position. If readData=true, the fragment of the data storage will be loaded and accessible in theDataBuffer.data()
Java array at the positionsDataBuffer.fromIndex()
..DataBuffer.toIndex()
-1. If readData=false, the behaviour is the same with the exception of reading data from the data storage is not guaranteed. This mode can be useful for optimization inDataBuffer.AccessMode.READ_WRITE
mode, if you are sure that you will fully rewrite all mapped elements and, so, want to save time by avoiding useless reading them.The passed position must be in range 0..length, where length is the total number of elements in the underlying data storage (for an AlgART array, its
Array.length()
). The number of actually mapped elements (DataBuffer.count()
) will be equal to min(maxCount,DataBuffer.capacity()
,length-position).This method should be used instead of the full
map(position)
version, if you need to access a less number of elements than the full buffer capacity or if you are going to fully rewrite all mapped elements.- Specified by:
map
in interfaceDataBuffer
- Parameters:
position
- new mapping position.maxCount
- this method does not guarantee that the elements after #position+maxCount-1 will be loaded into the buffer.readData
- if true, all mapped elements will be really loaded from the data storage; if false, there is no such a guarantee.- Returns:
- a reference to this data buffer.
- See Also:
-
force
DataDoubleBuffer force()Description copied from interface:DataBuffer
Writes all elements in the actual region of theDataBuffer.data()
Java array (fromDataBuffer.fromIndex()
, inclusive, toDataBuffer.toIndex()
, exclusive) back to the underlying data storage (usually AlgART array). May do nothing if the changes in this Java array reflect in the storage immediately (for example, for direct buffers).This method must be called to ensure that all changes, performed in the mapped data elements, will be reflected in the original data storage.
This method must not be called in the
READ
access mode. This method does nothing in thePRIVATE
access mode.- Specified by:
force
in interfaceDataBuffer
- Returns:
- a reference to this data buffer.
- See Also:
-
data
double[] data()Description copied from interface:DataBuffer
Returns the Java array which contains the mapped region of the data. The actual data elements are placed at the positionsDataBuffer.fromIndex()
..DataBuffer.toIndex()
-1. For bit elements, returned Java array is a packed long[] array, and the positions in this array should be considered in terms ofPackedBitArrays
class.The length of the returned array is always enough to fit the
DataBuffer.fromIndex()
..DataBuffer.toIndex()
-1 positions range in it.Note: this method returns null if map / mapNext methods were never called for this buffer yet, that is, if it is newly created.
Warning: the reference, returned by this method, may change after any call of map or mapNext methods.
- Specified by:
data
in interfaceDataBuffer
- Returns:
- the Java array which contains the mapped region of the data.
-