Class PointerBuffer
- java.lang.Object
-
- org.lwjgl.PointerBuffer
-
- All Implemented Interfaces:
- java.lang.Comparable<PointerBuffer>
public abstract class PointerBuffer extends java.lang.Object implements java.lang.Comparable<PointerBuffer>
This class is a container for architecture-independent pointer data. Its interface mirrors theLongBuffer
API for convenience.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description long
address0()
Returns the buffer's base address.static PointerBuffer
allocateDirect(int capacity)
Allocates a new pointer buffer.int
capacity()
Returns this buffer's capacity.PointerBuffer
clear()
Clears this buffer.PointerBuffer
compact()
Compacts this buffer (optional operation).int
compareTo(PointerBuffer that)
Compares this buffer to another.static PointerBuffer
create(java.nio.ByteBuffer source)
Creates a new PointerBuffer using the specified ByteBuffer as its pointer data source.static PointerBuffer
create(long address, int capacity)
Creates a new PointerBuffer that starts at the specified memory address and has the specified capacity.abstract PointerBuffer
duplicate()
Creates a new pointer buffer that shares this buffer's content.boolean
equals(java.lang.Object ob)
Tells whether or not this buffer is equal to another object.PointerBuffer
flip()
Flips this buffer.long
get()
Relative get method.static long
get(java.nio.ByteBuffer source)
Convenience relative get from a source ByteBuffer.static long
get(java.nio.ByteBuffer source, int index)
Convenience absolute get from a source ByteBuffer.long
get(int index)
Absolute get method.PointerBuffer
get(long[] dst)
Relative bulk get method.PointerBuffer
get(long[] dst, int offset, int length)
Relative bulk get method.java.nio.ByteBuffer
getByteBuffer(int size)
Returns a ByteBuffer instance that starts at the address found at the current position and has capacity equal to the specified size.java.nio.ByteBuffer
getByteBuffer(int index, int size)
Returns a ByteBuffer instance that starts at the address found at the specified index and has capacity equal to the specified size.java.nio.DoubleBuffer
getDoubleBuffer(int size)
Returns a DoubleBuffer instance that starts at the address found at the current position and has capacity equal to the specified size.java.nio.DoubleBuffer
getDoubleBuffer(int index, int size)
Returns a DoubleBuffer instance that starts at the address found at the specified index and has capacity equal to the specified size.java.nio.FloatBuffer
getFloatBuffer(int size)
Returns a FloatBuffer instance that starts at the address found at the current position and has capacity equal to the specified size.java.nio.FloatBuffer
getFloatBuffer(int index, int size)
Returns a FloatBuffer instance that starts at the address found at the specified index and has capacity equal to the specified size.java.nio.IntBuffer
getIntBuffer(int size)
Returns a IntBuffer instance that starts at the address found at the current position and has capacity equal to the specified size.java.nio.IntBuffer
getIntBuffer(int index, int size)
Returns a IntBuffer instance that starts at the address found at the specified index and has capacity equal to the specified size.java.nio.LongBuffer
getLongBuffer(int size)
Returns a LongBuffer instance that starts at the address found at the current position and has capacity equal to the specified size.java.nio.LongBuffer
getLongBuffer(int index, int size)
Returns a LongBuffer instance that starts at the address found at the specified index and has capacity equal to the specified size.PointerBuffer
getPointerBuffer(int size)
Returns a PointerBuffer instance that starts at the address found at the current position and has capacity equal to the specified size.PointerBuffer
getPointerBuffer(int index, int size)
Returns a PointerBuffer instance that starts at the address found at the specified index and has capacity equal to the specified size.java.nio.ShortBuffer
getShortBuffer(int size)
Returns a ShortBuffer instance that starts at the address found at the current position and has capacity equal to the specified size.java.nio.ShortBuffer
getShortBuffer(int index, int size)
Returns a ShortBuffer instance that starts at the address found at the specified index and has capacity equal to the specified size.java.lang.String
getStringASCII()
Decodes the ASCII string that starts at the address found at the current position.java.lang.String
getStringASCII(int index)
Decodes the ASCII string that starts at the address found at the specified index.java.lang.String
getStringUTF16()
Decodes the UTF-16 string that starts at the address found at the current position.java.lang.String
getStringUTF16(int index)
Decodes the UTF-16 string that starts at the address found at the specified index.java.lang.String
getStringUTF8()
Decodes the UTF-8 string that starts at the address found at the current position.java.lang.String
getStringUTF8(int index)
Decodes the UTF-8 string that starts at the address found at the specified index.int
hashCode()
Returns the current hash code of this buffer.boolean
hasRemaining()
Tells whether there are any elements between the current position and the limit.int
limit()
Returns this buffer's limit.PointerBuffer
limit(int newLimit)
Sets this buffer's limit.PointerBuffer
mark()
Sets this buffer's mark at its position.java.nio.ByteOrder
order()
Retrieves this buffer's byte order.int
position()
Returns this buffer's position.PointerBuffer
position(int newPosition)
Sets this buffer's position.PointerBuffer
put(java.nio.ByteBuffer buffer)
Puts the address of the specified buffer at the current position and then increments the position.static void
put(java.nio.ByteBuffer target, int index, long p)
Convenience absolute put on a target ByteBuffer.static void
put(java.nio.ByteBuffer target, long p)
Convenience relative put on a target ByteBuffer.PointerBuffer
put(java.nio.DoubleBuffer buffer)
Puts the address of the specified buffer at the current position and then increments the position.PointerBuffer
put(java.nio.FloatBuffer buffer)
Puts the address of the specified buffer at the current position and then increments the position.PointerBuffer
put(java.nio.IntBuffer buffer)
Puts the address of the specified buffer at the current position and then increments the position.PointerBuffer
put(int index, java.nio.ByteBuffer buffer)
Puts the address of the specified buffer at the specified index.PointerBuffer
put(int index, java.nio.DoubleBuffer buffer)
Puts the address of the specified buffer at the specified index.PointerBuffer
put(int index, java.nio.FloatBuffer buffer)
Puts the address of the specified buffer at the specified index.PointerBuffer
put(int index, java.nio.IntBuffer buffer)
Puts the address of the specified buffer at the specified index.PointerBuffer
put(int index, long p)
Absolute put method (optional operation).PointerBuffer
put(int index, java.nio.LongBuffer buffer)
Puts the address of the specified buffer at the specified index.PointerBuffer
put(int index, Pointer pointer)
Puts the pointer value of the specifiedPointer
at the specified index.PointerBuffer
put(int index, java.nio.ShortBuffer buffer)
Puts the address of the specified buffer at the specified index.PointerBuffer
put(long p)
Relative put method (optional operation).PointerBuffer
put(long[] src)
Relative bulk put method (optional operation).PointerBuffer
put(long[] src, int offset, int length)
Relative bulk put method (optional operation).PointerBuffer
put(java.nio.LongBuffer buffer)
Puts the address of the specified buffer at the current position and then increments the position.PointerBuffer
put(Pointer pointer)
Puts the pointer value of the specifiedPointer
at the current position and then increments the position.PointerBuffer
put(PointerBuffer src)
Relative bulk put method (optional operation).PointerBuffer
put(java.nio.ShortBuffer buffer)
Puts the address of the specified buffer at the current position and then increments the position.PointerBuffer
putAddressOf(int index, PointerBuffer buffer)
Puts the address of the specified buffer at the specified index.PointerBuffer
putAddressOf(PointerBuffer buffer)
Puts the address of the specified buffer at the current position and then increments the position.int
remaining()
Returns the number of elements between the current position and the limit.PointerBuffer
reset()
Resets this buffer's position to the previously-marked position.PointerBuffer
rewind()
Rewinds this buffer.static PointerBuffer
setup(PointerBuffer buffer, long address, int capacity)
abstract PointerBuffer
slice()
Creates a new pointer buffer whose content is a shared subsequence of this buffer's content.java.lang.String
toString()
Returns a string summarizing the state of this buffer.
-
-
-
Method Detail
-
allocateDirect
public static PointerBuffer allocateDirect(int capacity)
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:
java.lang.IllegalArgumentException
- If the capacity is a negative integer
-
create
public static PointerBuffer create(long address, int capacity)
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
public static PointerBuffer create(java.nio.ByteBuffer source)
Creates a new PointerBuffer using the specified ByteBuffer as its pointer data source.- Parameters:
source
- the source buffer
-
setup
public static PointerBuffer setup(PointerBuffer buffer, long address, int capacity)
-
address0
public long address0()
Returns the buffer's base address. [INTERNAL USE ONLY]
-
capacity
public int capacity()
Returns this buffer's capacity.- Returns:
- the capacity of this buffer
-
position
public int position()
Returns this buffer's position.- Returns:
- the position of this buffer
-
position
public PointerBuffer position(int newPosition)
Sets this buffer's position. If the mark is defined and larger than the new position then it is discarded.- Parameters:
newPosition
- the new position value; must be non-negative and no larger than the current limit- Returns:
- This buffer
- Throws:
java.lang.IllegalArgumentException
- If the preconditions on newPosition do not hold
-
limit
public int limit()
Returns this buffer's limit.- Returns:
- the limit of this buffer
-
limit
public PointerBuffer limit(int newLimit)
Sets this buffer's limit. If the position is larger than the new limit then it is set to the new limit. If the mark is defined and larger than the new limit then it is discarded.- Parameters:
newLimit
- the new limit value; must be non-negative and no larger than this buffer's capacity- Returns:
- This buffer
- Throws:
java.lang.IllegalArgumentException
- If the preconditions on newLimit do not hold
-
mark
public PointerBuffer mark()
Sets this buffer's mark at its position.- Returns:
- This buffer
-
reset
public PointerBuffer reset()
Resets this buffer's position to the previously-marked position.Invoking this method neither changes nor discards the mark's value.
- Returns:
- This buffer
- Throws:
java.nio.InvalidMarkException
- If the mark has not been set
-
clear
public PointerBuffer clear()
Clears this buffer. The position is set to zero, the limit is set to the capacity, and the mark is discarded.Invoke this method before using a sequence of channel-read or put operations to fill this buffer. For example:
buf.clear(); // Prepare buffer for reading in.read(buf); // Read data
This method does not actually erase the data in the buffer, but it is named as if it did because it will most often be used in situations in which that might as well be the case.
- Returns:
- This buffer
-
flip
public PointerBuffer flip()
Flips this buffer. The limit is set to the current position and then the position is set to zero. If the mark is defined then it is discarded.After a sequence of channel-read or put operations, invoke this method to prepare for a sequence of channel-write or relative get operations. For example:
buf.put(magic); // Prepend header in.read(buf); // Read data into rest of buffer buf.flip(); // Flip buffer out.write(buf); // Write header + data to channel
This method is often used in conjunction with the
PointerBuffer.compact()
method when transferring data from one place to another.- Returns:
- This buffer
-
rewind
public PointerBuffer rewind()
Rewinds this buffer. The position is set to zero and the mark is discarded.Invoke this method before a sequence of channel-write or get operations, assuming that the limit has already been set appropriately. For example:
out.write(buf); // Write remaining data buf.rewind(); // Rewind buffer buf.get(array); // Copy data into array
- Returns:
- This buffer
-
remaining
public int remaining()
Returns the number of elements between the current position and the limit.- Returns:
- the number of elements remaining in this buffer
-
hasRemaining
public boolean hasRemaining()
Tells whether there are any elements between the current position and the limit.- Returns:
- true if, and only if, there is at least one element remaining in this buffer
-
slice
public abstract PointerBuffer slice()
Creates a new pointer buffer whose content is a shared subsequence of this buffer's content.The content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent.
The new buffer's position will be zero, its capacity and its limit will be the number of pointers remaining in this buffer, and its mark will be undefined. The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only.
- Returns:
- the new pointer buffer
-
duplicate
public abstract PointerBuffer duplicate()
Creates a new pointer buffer that shares this buffer's content.The content of the new buffer will be that of this buffer. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent.
The new buffer's capacity, limit and position will be identical to those of this buffer.
- Returns:
- the new pointer buffer
-
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:
java.nio.BufferUnderflowException
- If the buffer's current position is not smaller than its limit
-
get
public static long get(java.nio.ByteBuffer source)
Convenience relative get from a source ByteBuffer.- Parameters:
source
- the source ByteBuffer
-
put
public PointerBuffer put(long p)
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:
java.nio.BufferOverflowException
- If this buffer's current position is not smaller than its limitjava.nio.ReadOnlyBufferException
- If this buffer is read-only
-
put
public static void put(java.nio.ByteBuffer target, long p)
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 specified index.- Parameters:
index
- the index from which the pointer will be read- Returns:
- the pointer at the specified index
- Throws:
java.lang.IndexOutOfBoundsException
- If index is negative or not smaller than the buffer's limit
-
get
public static long get(java.nio.ByteBuffer source, int index)
Convenience absolute get from a source ByteBuffer.- Parameters:
source
- the source ByteBufferindex
- the index at which the pointer will be read
-
put
public PointerBuffer put(int index, long p)
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:
java.lang.IndexOutOfBoundsException
- If index is negative or not smaller than the buffer's limitjava.nio.ReadOnlyBufferException
- If this buffer is read-only
-
put
public static void put(java.nio.ByteBuffer target, int index, long p)
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
public PointerBuffer put(Pointer pointer)
Puts the pointer value of the specifiedPointer
at the current position and then increments the position.
-
put
public PointerBuffer put(int index, Pointer pointer)
Puts the pointer value of the specifiedPointer
at the specified index.
-
put
public PointerBuffer put(java.nio.ByteBuffer buffer)
Puts the address of the specified buffer at the current position and then increments the position.
-
put
public PointerBuffer put(java.nio.ShortBuffer buffer)
Puts the address of the specified buffer at the current position and then increments the position.
-
put
public PointerBuffer put(java.nio.IntBuffer buffer)
Puts the address of the specified buffer at the current position and then increments the position.
-
put
public PointerBuffer put(java.nio.LongBuffer buffer)
Puts the address of the specified buffer at the current position and then increments the position.
-
put
public PointerBuffer put(java.nio.FloatBuffer buffer)
Puts the address of the specified buffer at the current position and then increments the position.
-
put
public PointerBuffer put(java.nio.DoubleBuffer buffer)
Puts the address of the specified buffer at the current position and then increments the position.
-
putAddressOf
public PointerBuffer putAddressOf(PointerBuffer buffer)
Puts the address of the specified buffer at the current position and then increments the position.
-
put
public PointerBuffer put(int index, java.nio.ByteBuffer buffer)
Puts the address of the specified buffer at the specified index.
-
put
public PointerBuffer put(int index, java.nio.ShortBuffer buffer)
Puts the address of the specified buffer at the specified index.
-
put
public PointerBuffer put(int index, java.nio.IntBuffer buffer)
Puts the address of the specified buffer at the specified index.
-
put
public PointerBuffer put(int index, java.nio.LongBuffer buffer)
Puts the address of the specified buffer at the specified index.
-
put
public PointerBuffer put(int index, java.nio.FloatBuffer buffer)
Puts the address of the specified buffer at the specified index.
-
put
public PointerBuffer put(int index, java.nio.DoubleBuffer buffer)
Puts the address of the specified buffer at the specified index.
-
putAddressOf
public PointerBuffer putAddressOf(int index, PointerBuffer buffer)
Puts the address of the specified buffer at the specified index.
-
getByteBuffer
public java.nio.ByteBuffer getByteBuffer(int size)
Returns a ByteBuffer instance that starts at the address found at the current position and has capacity equal to the specified size.
-
getShortBuffer
public java.nio.ShortBuffer getShortBuffer(int size)
Returns a ShortBuffer instance that starts at the address found at the current position and has capacity equal to the specified size.
-
getIntBuffer
public java.nio.IntBuffer getIntBuffer(int size)
Returns a IntBuffer instance that starts at the address found at the current position and has capacity equal to the specified size.
-
getLongBuffer
public java.nio.LongBuffer getLongBuffer(int size)
Returns a LongBuffer instance that starts at the address found at the current position and has capacity equal to the specified size.
-
getFloatBuffer
public java.nio.FloatBuffer getFloatBuffer(int size)
Returns a FloatBuffer instance that starts at the address found at the current position and has capacity equal to the specified size.
-
getDoubleBuffer
public java.nio.DoubleBuffer getDoubleBuffer(int size)
Returns a DoubleBuffer instance that starts at the address found at the current position and has capacity equal to the specified size.
-
getPointerBuffer
public PointerBuffer getPointerBuffer(int size)
Returns a PointerBuffer instance that starts at the address found at the current position and has capacity equal to the specified size.
-
getStringASCII
public java.lang.String getStringASCII()
Decodes the ASCII string that starts at the address found at the current position.
-
getStringUTF8
public java.lang.String getStringUTF8()
Decodes the UTF-8 string that starts at the address found at the current position.
-
getStringUTF16
public java.lang.String getStringUTF16()
Decodes the UTF-16 string that starts at the address found at the current position.
-
getByteBuffer
public java.nio.ByteBuffer getByteBuffer(int index, int size)
Returns a ByteBuffer instance that starts at the address found at the specified index and has capacity equal to the specified size.
-
getShortBuffer
public java.nio.ShortBuffer getShortBuffer(int index, int size)
Returns a ShortBuffer instance that starts at the address found at the specified index and has capacity equal to the specified size.
-
getIntBuffer
public java.nio.IntBuffer getIntBuffer(int index, int size)
Returns a IntBuffer instance that starts at the address found at the specified index and has capacity equal to the specified size.
-
getLongBuffer
public java.nio.LongBuffer getLongBuffer(int index, int size)
Returns a LongBuffer instance that starts at the address found at the specified index and has capacity equal to the specified size.
-
getFloatBuffer
public java.nio.FloatBuffer getFloatBuffer(int index, int size)
Returns a FloatBuffer instance that starts at the address found at the specified index and has capacity equal to the specified size.
-
getDoubleBuffer
public java.nio.DoubleBuffer getDoubleBuffer(int index, int size)
Returns a DoubleBuffer instance that starts at the address found at the specified index and has capacity equal to the specified size.
-
getPointerBuffer
public PointerBuffer getPointerBuffer(int index, int size)
Returns a PointerBuffer instance that starts at the address found at the specified index and has capacity equal to the specified size.
-
getStringASCII
public java.lang.String getStringASCII(int index)
Decodes the ASCII string that starts at the address found at the specified index.
-
getStringUTF8
public java.lang.String getStringUTF8(int index)
Decodes the UTF-8 string that starts at the address found at the specified index.
-
getStringUTF16
public java.lang.String getStringUTF16(int index)
Decodes the UTF-16 string that starts at the address found at the specified index.
-
get
public PointerBuffer get(long[] dst)
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 invocation
src.get(a, 0, a.length)
- Returns:
- This buffer
- Throws:
java.nio.BufferUnderflowException
- If there are fewer than length pointers remaining in this buffer
-
get
public PointerBuffer get(long[] dst, int offset, int length)
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 a
BufferUnderflowException
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 by length.
In other words, an invocation of this method of the form src.get(dst, off, len) has exactly the same effect as the loop
for (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 than dst.lengthlength
- the maximum number of pointers to be written to the specified array; must be non-negative and no larger than dst.length - offset- Returns:
- This buffer
- Throws:
java.nio.BufferUnderflowException
- If there are fewer than length pointers remaining in this bufferjava.lang.IndexOutOfBoundsException
- If the preconditions on the offset and length parameters do not hold
-
put
public PointerBuffer put(PointerBuffer src)
Relative bulk put method (optional operation).This method transfers the pointers remaining in the specified source buffer into this buffer. If there are more pointers remaining in the source buffer than in this buffer, that is, if src.remaining() > remaining(), then no pointers are transferred and a
BufferOverflowException
is thrown.Otherwise, this method copies n = src.remaining() pointers from the specified buffer into this buffer, starting at each buffer's current position. The positions of both buffers are then incremented by n.
In other words, an invocation of this method of the form dst.put(src) has exactly the same effect as the loop
while (src.hasRemaining()) dst.put(src.get());
except that it first checks that there is sufficient space in this buffer and it is potentially much more efficient.
- Parameters:
src
- the source buffer from which pointers are to be read; must not be this buffer- Returns:
- This buffer
- Throws:
java.nio.BufferOverflowException
- If there is insufficient space in this buffer for the remaining pointers in the source bufferjava.lang.IllegalArgumentException
- If the source buffer is this bufferjava.nio.ReadOnlyBufferException
- If this buffer is read-only
-
put
public PointerBuffer put(long[] src)
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 invocation
dst.put(a, 0, a.length)
- Returns:
- This buffer
- Throws:
java.nio.BufferOverflowException
- If there is insufficient space in this bufferjava.nio.ReadOnlyBufferException
- If this buffer is read-only
-
put
public PointerBuffer put(long[] src, int offset, int length)
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 a
BufferOverflowException
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 by length.
In other words, an invocation of this method of the form dst.put(src, off, len) has exactly the same effect as the loop
for (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 than array.lengthlength
- the number of pointers to be read from the specified array; must be non-negative and no larger than array.length - offset- Returns:
- This buffer
- Throws:
java.nio.BufferOverflowException
- If there is insufficient space in this bufferjava.lang.IndexOutOfBoundsException
- If the preconditions on the offset and length parameters do not holdjava.nio.ReadOnlyBufferException
- If this buffer is read-only
-
compact
public PointerBuffer compact()
Compacts this buffer (optional operation).The pointers between the buffer's current position and its limit, if any, are copied to the beginning of the buffer. That is, the pointer at index p = position() is copied to index zero, the pointer at index p + 1 is copied to index one, and so forth until the pointer at index limit() - 1 is copied to index n = limit() - 1 - p. The buffer's position is then set to n+1 and its limit is set to its capacity. The mark, if defined, is discarded.
The buffer's position is set to the number of pointers copied, rather than to zero, so that an invocation of this method can be followed immediately by an invocation of another relative put method.
- Returns:
- This buffer
- Throws:
java.nio.ReadOnlyBufferException
- If this buffer is read-only
-
order
public java.nio.ByteOrder order()
Retrieves this buffer's byte order.The byte order of a pointer buffer created by allocation or by wrapping an existing pointer array is the
native order
of the underlying hardware. The byte order of a pointer buffer created as a view of a byte buffer is that of the byte buffer at the moment that the view is created.
- Returns:
- This buffer's byte order
-
toString
public java.lang.String toString()
Returns a string summarizing the state of this buffer.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A summary string
-
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 at limit() - 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 classjava.lang.Object
- Returns:
- the current hash code of this buffer
-
equals
public boolean equals(java.lang.Object ob)
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 classjava.lang.Object
- 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
public int compareTo(PointerBuffer that)
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 interfacejava.lang.Comparable<PointerBuffer>
- Returns:
- A negative integer, zero, or a positive integer as this buffer is less than, equal to, or greater than the specified buffer
-
-