Module org.tensorflow.ndarray
Class AbstractDataBufferWindow<B extends DataBuffer<?>>
- java.lang.Object
-
- org.tensorflow.ndarray.impl.buffer.AbstractDataBufferWindow<B>
-
- All Implemented Interfaces:
DataBufferWindow<B>
public abstract class AbstractDataBufferWindow<B extends DataBuffer<?>> extends Object implements DataBufferWindow<B>
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractDataBufferWindow(B windowBuffer, long bufferLimit)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Bbuffer()Returns the buffer backing this window.longoffset()Returns the current offset of this window in the original buffer.protected abstract voidoffset(long offset)longsize()Returns the size of this buffer window.DataBufferWindow<B>slide(long step)Moves the window ofstepelements in the original buffer.DataBufferWindow<B>slideTo(long index)Moves the window at the given position in the original buffer.
-
-
-
Constructor Detail
-
AbstractDataBufferWindow
protected AbstractDataBufferWindow(B windowBuffer, long bufferLimit)
-
-
Method Detail
-
offset
public final long offset()
Description copied from interface:DataBufferWindowReturns the current offset of this window in the original buffer.- Specified by:
offsetin interfaceDataBufferWindow<B extends DataBuffer<?>>
-
size
public final long size()
Description copied from interface:DataBufferWindowReturns the size of this buffer window.- Specified by:
sizein interfaceDataBufferWindow<B extends DataBuffer<?>>
-
slideTo
public final DataBufferWindow<B> slideTo(long index)
Description copied from interface:DataBufferWindowMoves the window at the given position in the original buffer.The size of the window remains the same and its offset is set to
index, so that accessing the value ofDataBufferWindow.buffer()at indexxwill return the value atindex + xin the original buffer.- Specified by:
slideToin interfaceDataBufferWindow<B extends DataBuffer<?>>- Parameters:
index- new offset for this window- Returns:
- this instance
-
slide
public final DataBufferWindow<B> slide(long step)
Description copied from interface:DataBufferWindowMoves the window ofstepelements in the original buffer.The size of the window remains the same and its offset is set to
offset() + step. Ifstepis positive, then the window will slide forward. If it is negative, it will slide backward.- Specified by:
slidein interfaceDataBufferWindow<B extends DataBuffer<?>>- Parameters:
step- value to add to the current offset of this window- Returns:
- this instance
-
buffer
public final B buffer()
Description copied from interface:DataBufferWindowReturns the buffer backing this window.Each window instance has it's own buffer providing a view onto the original
DataBuffer. The buffers are mutated when the window slides to different offsets. For example:IntDataBuffer buffer = DataBuffers.of(0, 1, 2, 3); DataBufferWindow<IntDataBuffer> window = buffer.window(0, 2); IntDataBuffer windowBuffer = window.buffer(); assertEquals(0, windowBuffer.getInt(0)); assertEquals(1, windowBuffer.getInt(1)); window.slideTo(2); assertEquals(2, windowBuffer.getInt(0)); assertEquals(3, windowBuffer.getInt(1)); assertSame(windowBuffer, window.buffer());- Specified by:
bufferin interfaceDataBufferWindow<B extends DataBuffer<?>>- Returns:
- this window's buffer
-
offset
protected abstract void offset(long offset)
-
-