Class PointerBuffer
- All Implemented Interfaces:
Comparable<PointerBuffer>
,Pointer
LongBuffer
API for convenience.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.lwjgl.system.Pointer
Pointer.Default
-
Field Summary
Fields inherited from interface org.lwjgl.system.Pointer
BITS32, BITS64, CLONG_SHIFT, CLONG_SIZE, POINTER_SHIFT, POINTER_SIZE
-
Method Summary
Modifier and TypeMethodDescriptionstatic PointerBuffer
allocateDirect
(int capacity) Allocates a new pointer buffer.int
compareTo
(PointerBuffer that) Compares this buffer to another.static PointerBuffer
create
(long address, int capacity) Creates a new PointerBuffer that starts at the specified memory address and has the specified capacity.static PointerBuffer
create
(ByteBuffer source) Creates a new PointerBuffer using the specified ByteBuffer as its pointer data source.boolean
Tells whether or not this buffer is equal to another object.long
get()
Relative get method.long
get
(int index) Absolute get method.get
(long[] dst) Relative bulk get method.get
(long[] dst, int offset, int length) Relative bulk get method.static long
get
(ByteBuffer source) Convenience relative get from a source ByteBuffer.static long
get
(ByteBuffer source, int index) Convenience absolute get from a source ByteBuffer.getByteBuffer
(int size) Reads the pointer at this buffer's current position, and then increments the position.getByteBuffer
(int index, int size) Returns aByteBuffer
instance that starts at the address found at the specifiedindex
and has capacity equal to the specified size.getDoubleBuffer
(int size) Reads the pointer at this buffer's current position, and then increments the position.getDoubleBuffer
(int index, int size) Returns aDoubleBuffer
instance that starts at the address found at the specifiedindex
and has capacity equal to the specified size.getFloatBuffer
(int size) Reads the pointer at this buffer's current position, and then increments the position.getFloatBuffer
(int index, int size) Returns aFloatBuffer
instance that starts at the address found at the specifiedindex
and has capacity equal to the specified size.getIntBuffer
(int size) Reads the pointer at this buffer's current position, and then increments the position.getIntBuffer
(int index, int size) Returns aIntBuffer
instance that starts at the address found at the specifiedindex
and has capacity equal to the specified size.getLongBuffer
(int size) Reads the pointer at this buffer's current position, and then increments the position.getLongBuffer
(int index, int size) Returns aLongBuffer
instance that starts at the address found at the specifiedindex
and has capacity equal to the specified size.getPointerBuffer
(int size) Reads the pointer at this buffer's current position, and then increments the position.getPointerBuffer
(int index, int size) Returns aPointerBuffer
instance that starts at the address found at the specifiedindex
and has capacity equal to the specified size.getShortBuffer
(int size) Reads the pointer at this buffer's current position, and then increments the position.getShortBuffer
(int index, int size) Returns aShortBuffer
instance that starts at the address found at the specifiedindex
and has capacity equal to the specified size.Reads the pointer at this buffer's current position, and then increments the position.getStringASCII
(int index) Decodes the ASCII string that starts at the address found at the specifiedindex
.Reads the pointer at this buffer's current position, and then increments the position.getStringUTF16
(int index) Decodes the UTF-16 string that starts at the address found at the specifiedindex
.Reads the pointer at this buffer's current position, and then increments the position.getStringUTF8
(int index) Decodes the UTF-8 string that starts at the address found at the specifiedindex
.int
hashCode()
Returns the current hash code of this buffer.put
(int index, long p) Absolute put method (optional operation).put
(int index, ByteBuffer buffer) Puts the address of the specifiedbuffer
at the specifiedindex
.put
(int index, DoubleBuffer buffer) Puts the address of the specifiedbuffer
at the specifiedindex
.put
(int index, FloatBuffer buffer) Puts the address of the specifiedbuffer
at the specifiedindex
.Puts the address of the specifiedbuffer
at the specifiedindex
.put
(int index, LongBuffer buffer) Puts the address of the specifiedbuffer
at the specifiedindex
.put
(int index, ShortBuffer buffer) Puts the address of the specifiedbuffer
at the specifiedindex
.Puts the pointer value of the specifiedPointer
at the specifiedindex
.put
(long p) Relative put method (optional operation).put
(long[] src) Relative bulk put method (optional operation).put
(long[] src, int offset, int length) Relative bulk put method (optional operation).put
(ByteBuffer buffer) Writes the address of the specifiedbuffer
into this buffer at the current position, and then increments the position.static void
put
(ByteBuffer target, int index, long p) Convenience absolute put on a target ByteBuffer.static void
put
(ByteBuffer target, long p) Convenience relative put on a target ByteBuffer.put
(DoubleBuffer buffer) Writes the address of the specifiedbuffer
into this buffer at the current position, and then increments the position.put
(FloatBuffer buffer) Writes the address of the specifiedbuffer
into this buffer at the current position, and then increments the position.Writes the address of the specifiedbuffer
into this buffer at the current position, and then increments the position.put
(LongBuffer buffer) Writes the address of the specifiedbuffer
into this buffer at the current position, and then increments the position.put
(ShortBuffer buffer) Writes the address of the specifiedbuffer
into this buffer at the current position, and then increments the position.Puts the pointer value of the specifiedPointer
at the current position and then increments the position.putAddressOf
(int index, CustomBuffer<?> buffer) Puts the address of the specifiedbuffer
at the specifiedindex
.putAddressOf
(CustomBuffer<?> buffer) Writes the address of the specifiedbuffer
into this buffer at the current position, and then increments the position.int
sizeof()
Returns thesizeof
a single element in the buffer.
-
Method Details
-
allocateDirect
Allocates a new pointer buffer.The new buffer's position will be zero, its limit will be its capacity, and its mark will be undefined.
- Parameters:
capacity
- the new buffer's capacity, in pointers- Returns:
- the new pointer buffer
- Throws:
IllegalArgumentException
- If thecapacity
is a negative integer
-
create
Creates a new PointerBuffer that starts at the specified memory address and has the specified capacity.- Parameters:
address
- the starting memory addresscapacity
- the buffer capacity, in number of pointers
-
create
Creates a new PointerBuffer using the specified ByteBuffer as its pointer data source.- Parameters:
source
- the source buffer
-
sizeof
public int sizeof()Description copied from class:CustomBuffer
Returns thesizeof
a single element in the buffer.- Specified by:
sizeof
in classCustomBuffer<PointerBuffer>
-
get
public long get()Relative get method. Reads the pointer at this buffer's current position, and then increments the position.- Returns:
- the pointer at the buffer's current position
- Throws:
BufferUnderflowException
- If the buffer's current position is not smaller than its limit
-
get
Convenience relative get from a source ByteBuffer.- Parameters:
source
- the source ByteBuffer
-
put
Relative put method (optional operation).Writes the specified pointer into this buffer at the current position, and then increments the position.
- Parameters:
p
- the pointer to be written- Returns:
- This buffer
- Throws:
BufferOverflowException
- If this buffer's current position is not smaller than its limit
-
put
Convenience relative put on a target ByteBuffer.- Parameters:
target
- the target ByteBufferp
- the pointer value to be written
-
get
public long get(int index) Absolute get method. Reads the pointer at the specifiedindex
.- Parameters:
index
- the index from which the pointer will be read- Returns:
- the pointer at the specified
index
- Throws:
IndexOutOfBoundsException
- Ifindex
is negative or not smaller than the buffer's limit
-
get
Convenience absolute get from a source ByteBuffer.- Parameters:
source
- the source ByteBufferindex
- the index at which the pointer will be read
-
put
Absolute put method (optional operation).Writes the specified pointer into this buffer at the specified
index
.- Parameters:
index
- the index at which the pointer will be writtenp
- the pointer value to be written- Returns:
- This buffer
- Throws:
IndexOutOfBoundsException
- Ifindex
is negative or not smaller than the buffer's limit
-
put
Convenience absolute put on a target ByteBuffer.- Parameters:
target
- the target ByteBufferindex
- the index at which the pointer will be writtenp
- the pointer value to be written
-
put
Puts the pointer value of the specifiedPointer
at the current position and then increments the position. -
put
Puts the pointer value of the specifiedPointer
at the specifiedindex
. -
put
Writes the address of the specified
buffer
into this buffer at the current position, and then increments the position.- Parameters:
buffer
- the pointer to be written- Returns:
- this buffer
- Throws:
BufferOverflowException
- If this buffer's current position is not smaller than its limit
-
put
Writes the address of the specified
buffer
into this buffer at the current position, and then increments the position.- Parameters:
buffer
- the pointer to be written- Returns:
- this buffer
- Throws:
BufferOverflowException
- If this buffer's current position is not smaller than its limit
-
put
Writes the address of the specified
buffer
into this buffer at the current position, and then increments the position.- Parameters:
buffer
- the pointer to be written- Returns:
- this buffer
- Throws:
BufferOverflowException
- If this buffer's current position is not smaller than its limit
-
put
Writes the address of the specified
buffer
into this buffer at the current position, and then increments the position.- Parameters:
buffer
- the pointer to be written- Returns:
- this buffer
- Throws:
BufferOverflowException
- If this buffer's current position is not smaller than its limit
-
put
Writes the address of the specified
buffer
into this buffer at the current position, and then increments the position.- Parameters:
buffer
- the pointer to be written- Returns:
- this buffer
- Throws:
BufferOverflowException
- If this buffer's current position is not smaller than its limit
-
put
Writes the address of the specified
buffer
into this buffer at the current position, and then increments the position.- Parameters:
buffer
- the pointer to be written- Returns:
- this buffer
- Throws:
BufferOverflowException
- If this buffer's current position is not smaller than its limit
-
putAddressOf
Writes the address of the specified
buffer
into this buffer at the current position, and then increments the position.- Parameters:
buffer
- the pointer to be written- Returns:
- this buffer
- Throws:
BufferOverflowException
- If this buffer's current position is not smaller than its limit
-
put
Puts the address of the specifiedbuffer
at the specifiedindex
. -
put
Puts the address of the specifiedbuffer
at the specifiedindex
. -
put
Puts the address of the specifiedbuffer
at the specifiedindex
. -
put
Puts the address of the specifiedbuffer
at the specifiedindex
. -
put
Puts the address of the specifiedbuffer
at the specifiedindex
. -
put
Puts the address of the specifiedbuffer
at the specifiedindex
. -
putAddressOf
Puts the address of the specifiedbuffer
at the specifiedindex
. -
getByteBuffer
Reads the pointer at this buffer's current position, and then increments the position. The pointer is returned as aByteBuffer
instance that starts at the pointer address and has capacity equal to the specifiedsize
.- Throws:
BufferUnderflowException
- If the buffer's current position is not smaller than its limit
-
getShortBuffer
Reads the pointer at this buffer's current position, and then increments the position. The pointer is returned as aShortBuffer
instance that starts at the pointer address and has capacity equal to the specifiedsize
.- Throws:
BufferUnderflowException
- If the buffer's current position is not smaller than its limit
-
getIntBuffer
Reads the pointer at this buffer's current position, and then increments the position. The pointer is returned as aIntBuffer
instance that starts at the pointer address and has capacity equal to the specifiedsize
.- Throws:
BufferUnderflowException
- If the buffer's current position is not smaller than its limit
-
getLongBuffer
Reads the pointer at this buffer's current position, and then increments the position. The pointer is returned as aLongBuffer
instance that starts at the pointer address and has capacity equal to the specifiedsize
.- Throws:
BufferUnderflowException
- If the buffer's current position is not smaller than its limit
-
getFloatBuffer
Reads the pointer at this buffer's current position, and then increments the position. The pointer is returned as aFloatBuffer
instance that starts at the pointer address and has capacity equal to the specifiedsize
.- Throws:
BufferUnderflowException
- If the buffer's current position is not smaller than its limit
-
getDoubleBuffer
Reads the pointer at this buffer's current position, and then increments the position. The pointer is returned as aDoubleBuffer
instance that starts at the pointer address and has capacity equal to the specifiedsize
.- Throws:
BufferUnderflowException
- If the buffer's current position is not smaller than its limit
-
getPointerBuffer
Reads the pointer at this buffer's current position, and then increments the position. The pointer is returned as aPointerBuffer
instance that starts at the pointer address and has capacity equal to the specifiedsize
.- Throws:
BufferUnderflowException
- If the buffer's current position is not smaller than its limit
-
getStringASCII
Reads the pointer at this buffer's current position, and then increments the position. The pointer is evaluated as a null-terminated ASCII string, which is decoded and returned as aString
instance.- Throws:
BufferUnderflowException
- If the buffer's current position is not smaller than its limit
-
getStringUTF8
Reads the pointer at this buffer's current position, and then increments the position. The pointer is evaluated as a null-terminated UTF-8 string, which is decoded and returned as aString
instance.- Throws:
BufferUnderflowException
- If the buffer's current position is not smaller than its limit
-
getStringUTF16
Reads the pointer at this buffer's current position, and then increments the position. The pointer is evaluated as a null-terminated UTF-16 string, which is decoded and returned as aString
instance.- Throws:
BufferUnderflowException
- If the buffer's current position is not smaller than its limit
-
getByteBuffer
Returns aByteBuffer
instance that starts at the address found at the specifiedindex
and has capacity equal to the specified size. -
getShortBuffer
Returns aShortBuffer
instance that starts at the address found at the specifiedindex
and has capacity equal to the specified size. -
getIntBuffer
Returns aIntBuffer
instance that starts at the address found at the specifiedindex
and has capacity equal to the specified size. -
getLongBuffer
Returns aLongBuffer
instance that starts at the address found at the specifiedindex
and has capacity equal to the specified size. -
getFloatBuffer
Returns aFloatBuffer
instance that starts at the address found at the specifiedindex
and has capacity equal to the specified size. -
getDoubleBuffer
Returns aDoubleBuffer
instance that starts at the address found at the specifiedindex
and has capacity equal to the specified size. -
getPointerBuffer
Returns aPointerBuffer
instance that starts at the address found at the specifiedindex
and has capacity equal to the specified size. -
getStringASCII
Decodes the ASCII string that starts at the address found at the specifiedindex
. -
getStringUTF8
Decodes the UTF-8 string that starts at the address found at the specifiedindex
. -
getStringUTF16
Decodes the UTF-16 string that starts at the address found at the specifiedindex
. -
get
Relative bulk get method.This method transfers pointers from this buffer into the specified destination array. An invocation of this method of the form
src.get(a)
behaves in exactly the same way as the invocationsrc.get(a, 0, a.length)
- Returns:
- This buffer
- Throws:
BufferUnderflowException
- If there are fewer thanlength
pointers remaining in this buffer
-
get
Relative bulk get method.This method transfers pointers from this buffer into the specified destination array. If there are fewer pointers remaining in the buffer than are required to satisfy the request, that is, if
length
>
remaining()
, then no pointers are transferred and aBufferUnderflowException
is thrown.Otherwise, this method copies
length
pointers from this buffer into the specified array, starting at the current position of this buffer and at the specified offset in the array. The position of this buffer is then incremented bylength
.In other words, an invocation of this method of the form
src.get(dst, off, len)
has exactly the same effect as the loopfor (int i = off; i < off + len; i++) dst[i] = src.get();
except that it first checks that there are sufficient pointers in this buffer and it is potentially much more efficient.
- Parameters:
dst
- the array into which pointers are to be writtenoffset
- the offset within the array of the first pointer to be written; must be non-negative and no larger thandst.length
length
- the maximum number of pointers to be written to the specified array; must be non-negative and no larger thandst.length - offset
- Returns:
- This buffer
- Throws:
BufferUnderflowException
- If there are fewer thanlength
pointers remaining in this bufferIndexOutOfBoundsException
- If the preconditions on theoffset
andlength
parameters do not hold
-
put
Relative bulk put method (optional operation).This method transfers the entire content of the specified source pointer array into this buffer. An invocation of this method of the form
dst.put(a)
behaves in exactly the same way as the invocationdst.put(a, 0, a.length)
- Returns:
- This buffer
- Throws:
BufferOverflowException
- If there is insufficient space in this buffer
-
put
Relative bulk put method (optional operation).This method transfers pointers into this buffer from the specified source array. If there are more pointers to be copied from the array than remain in this buffer, that is, if
length
>
remaining()
, then no pointers are transferred and aBufferOverflowException
is thrown.Otherwise, this method copies
length
pointers from the specified array into this buffer, starting at the specified offset in the array and at the current position of this buffer. The position of this buffer is then incremented bylength
.In other words, an invocation of this method of the form
dst.put(src, off, len)
has exactly the same effect as the loopfor (int i = off; i < off + len; i++) dst.put(a[i]);
except that it first checks that there is sufficient space in this buffer and it is potentially much more efficient.
- Parameters:
src
- the array from which pointers are to be readoffset
- the offset within the array of the first pointer to be read; must be non-negative and no larger thanarray.length
length
- the number of pointers to be read from the specified array; must be non-negative and no larger thanarray.length - offset
- Returns:
- This buffer
- Throws:
BufferOverflowException
- If there is insufficient space in this bufferIndexOutOfBoundsException
- If the preconditions on theoffset
andlength
parameters do not hold
-
hashCode
public int hashCode()Returns the current hash code of this buffer.The hash code of a pointer buffer depends only upon its remaining elements; that is, upon the elements from
position()
up to, and including, the element atlimit()
-1
.Because buffer hash codes are content-dependent, it is inadvisable to use buffers as keys in hash maps or similar data structures unless it is known that their contents will not change.
- Overrides:
hashCode
in classPointer.Default
- Returns:
- the current hash code of this buffer
-
equals
Tells whether or not this buffer is equal to another object.Two pointer buffers are equal if, and only if,
- They have the same element type,
- They have the same number of remaining elements, and
- The two sequences of remaining elements, considered independently of their starting positions, are pointwise equal.
A pointer buffer is not equal to any other type of object.
- Overrides:
equals
in classPointer.Default
- Parameters:
ob
- the object to which this buffer is to be compared- Returns:
true
if, and only if, this buffer is equal to the given object
-
compareTo
Compares this buffer to another.Two pointer buffers are compared by comparing their sequences of remaining elements lexicographically, without regard to the starting position of each sequence within its corresponding buffer.
A pointer buffer is not comparable to any other type of object.
- Specified by:
compareTo
in interfaceComparable<PointerBuffer>
- Returns:
- A negative integer, zero, or a positive integer as this buffer is less than, equal to, or greater than the specified buffer
-