Package com.jogamp.common.nio
Class PointerBuffer
- java.lang.Object
-
- com.jogamp.common.nio.AbstractBuffer<PointerBuffer>
-
- com.jogamp.common.nio.PointerBuffer
-
- All Implemented Interfaces:
NativeBuffer<PointerBuffer>
public class PointerBuffer extends AbstractBuffer<PointerBuffer>
Hardware independent container holding an array of native pointer, while itsAbstractBuffer.getDirectBufferAddress()
is-a pointer-pointer type value.An instance maps an array of pointers of referenced Buffer objects, represented as longs.
The native values (NIO direct ByteBuffer) might be 32bit or 64bit wide, depending of the CPU pointer width, see
AbstractBuffer.POINTER_SIZE
.- Author:
- Sven Gothel, Michael Bien
-
-
Field Summary
Fields Modifier and Type Field Description protected LongObjectHashMap
dataMap
-
Fields inherited from class com.jogamp.common.nio.AbstractBuffer
buffer, capacity, elementSize, limit, POINTER_SIZE, position
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PointerBuffer
allocate(int size)
Returns a non direct PointerBuffer, having a backup arraystatic PointerBuffer
allocateDirect(int size)
Returns a direct PointerBuffer in native order, w/o backup arraystatic PointerBuffer
derefPointer(long aptr, int elemCount)
static PointerBuffer
derefPointer(ByteBuffer ptrSrc, int ptrSrcByteOffset, int elemCount)
PointerBuffer
duplicate()
long
get()
Relative get method.long
get(int idx)
Absolute get method.PointerBuffer
get(int srcElemPos, long[] dest, int destElemPos, int elemCount)
Absolute get method.PointerBuffer
get(long[] dest, int destElemPos, int elemCount)
Relative bulk get method.Buffer
getReferencedBuffer()
Buffer
getReferencedBuffer(int index)
PointerBuffer
put(int idx, long v)
Absolute put method.PointerBuffer
put(long value)
Relative put method.PointerBuffer
put(long[] src, int srcElemPos, int elemCount)
Relative bulk put method.PointerBuffer
put(long[] src, int srcElemPos, int destElemPos, int elemCount)
Absolute put method.PointerBuffer
put(PointerBuffer src)
Relative bulk get method.PointerBuffer
referenceBuffer(int index, Buffer bb)
Put the address of the given direct Buffer at the given position of this pointer array.PointerBuffer
referenceBuffer(Buffer bb)
Put the address of the given direct Buffer at the end of this pointer array.String
toString()
static PointerBuffer
wrap(ByteBuffer src)
static PointerBuffer
wrap(ByteBuffer src, int srcByteOffset, int elemCount)
-
Methods inherited from class com.jogamp.common.nio.AbstractBuffer
array, arrayOffset, capacity, clear, elementSize, flip, getBuffer, getDirectBufferAddress, hasArray, hasRemaining, isDirect, limit, limit, position, position, remaining, rewind, storeDirectAddress, storeDirectAddress, toSubString
-
-
-
-
Field Detail
-
dataMap
protected LongObjectHashMap dataMap
-
-
Method Detail
-
allocate
public static PointerBuffer allocate(int size)
Returns a non direct PointerBuffer, having a backup array
-
allocateDirect
public static PointerBuffer allocateDirect(int size)
Returns a direct PointerBuffer in native order, w/o backup array
-
wrap
public static PointerBuffer wrap(ByteBuffer src)
-
wrap
public static PointerBuffer wrap(ByteBuffer src, int srcByteOffset, int elemCount)
- Parameters:
src
-srcByteOffset
-elemCount
-- Returns:
-
derefPointer
public static PointerBuffer derefPointer(long aptr, int elemCount)
-
derefPointer
public static PointerBuffer derefPointer(ByteBuffer ptrSrc, int ptrSrcByteOffset, int elemCount)
-
duplicate
public final PointerBuffer duplicate()
- Returns:
- new PointerBuffer sharing the same buffer data of this instance (identity), but having an independent position.
-
put
public final PointerBuffer put(PointerBuffer src)
Description copied from interface:NativeBuffer
Relative bulk get method. Copy the source valuessrc[position .. capacity] [
to this buffer and increment the position bycapacity-position
.
-
get
public final long get(int idx)
Absolute get method. Get the pointer value at the given index
-
get
public final long get()
Relative get method. Get the pointer value at the current position and increment the position by one.
-
get
public final PointerBuffer get(int srcElemPos, long[] dest, int destElemPos, int elemCount)
Absolute get method. Get element-bytes for `elemCount` elements from this buffer at `srcElemPos` into `dest` at the given element-index `destElemPos`
-
get
public final PointerBuffer get(long[] dest, int destElemPos, int elemCount)
Relative bulk get method. Copy the pointer values[ position .. position+elemCount [
to the destination array[ dest[destElemPos] .. dest[destElemPos+elemCount] [
and increment the position byelemCount
.
-
put
public final PointerBuffer put(int idx, long v)
Absolute put method. Put the pointer value at the given index
-
put
public final PointerBuffer put(long value)
Relative put method. Put the pointer value at the current position and increment the position by one.
-
put
public final PointerBuffer put(long[] src, int srcElemPos, int destElemPos, int elemCount)
Absolute put method. Put element-bytes for `elemCount` elements from `src` at `srcElemPos` into this buffer at the given element-index `destElemPos`
-
put
public final PointerBuffer put(long[] src, int srcElemPos, int elemCount)
Relative bulk put method. Put the pointer values[ src[srcElemPos] .. src[srcElemPos+elemCount] [
at the current position and increment the position byelemCount
.
-
referenceBuffer
public final PointerBuffer referenceBuffer(int index, Buffer bb)
Put the address of the given direct Buffer at the given position of this pointer array. Adding a reference of the given direct Buffer to this object.- Throws:
IllegalArgumentException
- if bb is null or not a direct buffer
-
referenceBuffer
public final PointerBuffer referenceBuffer(Buffer bb)
Put the address of the given direct Buffer at the end of this pointer array. Adding a reference of the given direct Buffer to this object.
-
getReferencedBuffer
public final Buffer getReferencedBuffer(int index)
-
getReferencedBuffer
public final Buffer getReferencedBuffer()
-
toString
public String toString()
- Overrides:
toString
in classAbstractBuffer<PointerBuffer>
-
-