Interface DataObjectBuffer<E>
- All Superinterfaces:
DataBuffer
Data buffer for Object elements.
- Author:
- Daniel Alievsky
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.algart.arrays.DataBuffer
DataBuffer.AccessMode
-
Method Summary
Modifier and TypeMethodDescriptionE[]
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.mapNext()
Maps the next region in the underlying data storage (usually AlgART array).
-
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:
-
mapNext
DataObjectBuffer<E> 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:
-
force
DataObjectBuffer<E> 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
E[] 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.
-