com.jogamp.common.nio
Class PointerBuffer

java.lang.Object
  extended by com.jogamp.common.nio.AbstractBuffer<PointerBuffer>
      extended by com.jogamp.common.nio.PointerBuffer
All Implemented Interfaces:
NativeBuffer<PointerBuffer>

public class PointerBuffer
extends AbstractBuffer<PointerBuffer>

Hardware independent container for native pointer arrays. The native values (NIO direct ByteBuffer) might be 32bit or 64bit wide, depending of the CPU pointer width.

Author:
Sven Gothel, Michael Bien

Field Summary
protected  LongObjectHashMap dataMap
           
static int ELEMENT_SIZE
           
 
Fields inherited from class com.jogamp.common.nio.AbstractBuffer
buffer, capacity, elementSize, position
 
Method Summary
static PointerBuffer allocate(int size)
          Returns a non direct PointerBuffer in native order, having a backup array
static PointerBuffer allocateDirect(int size)
          Returns a direct PointerBuffer in native order, w/o backup array
 PointerBuffer duplicate()
           
 long get()
          Relative get method.
 long get(int idx)
          Absolute get method.
 PointerBuffer get(long[] dest, int offset, int length)
          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 offset, int length)
          Relative bulk put method.
 PointerBuffer put(PointerBuffer src)
          Relative bulk get method.
 PointerBuffer referenceBuffer(Buffer bb)
          Put the address of the given direct Buffer at the end of this pointer array.
 PointerBuffer referenceBuffer(int index, Buffer bb)
          Put the address of the given direct Buffer at the given position of this pointer array.
 String toString()
           
static PointerBuffer wrap(ByteBuffer src)
           
 
Methods inherited from class com.jogamp.common.nio.AbstractBuffer
array, arrayOffset, capacity, elementSize, getBuffer, hasArray, hasRemaining, isDirect, limit, position, position, remaining, rewind
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ELEMENT_SIZE

public static final int ELEMENT_SIZE

dataMap

protected LongObjectHashMap dataMap
Method Detail

allocate

public static PointerBuffer allocate(int size)
Returns a non direct PointerBuffer in native order, 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)

duplicate

public final PointerBuffer duplicate()
Returns:
new PointerBuffer sharing the same buffer data of this instance (identity), but having independent position, limit and capacity.

put

public final PointerBuffer put(PointerBuffer src)
Relative bulk get method. Copy the source values src[position .. capacity] [ to this buffer and increment the position by capacity-position.


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 long get(int idx)
Absolute get method. Get the pointer value at the given index


get

public final PointerBuffer get(long[] dest,
                               int offset,
                               int length)
Relative bulk get method. Copy the pointer values [ position .. position+length [ to the destination array [ dest[offset] .. dest[offset+length] [ and increment the position by length.


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 offset,
                               int length)
Relative bulk put method. Put the pointer values [ src[offset] .. src[offset+length] [ at the current position and increment the position by length.


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 class AbstractBuffer<PointerBuffer>