| Modifier and Type | Class and Description |
|---|---|
| private static class | PointerBuffer.
Read-only version of PointerBuffer. |
| Modifier and Type | Field and Description |
|---|---|
| private static final boolean | |
| protected final ByteBuffer | |
| protected final Buffer | |
| protected final IntBuffer | |
| protected final LongBuffer |
| Access | Constructor and Description |
|---|---|
| public | PointerBuffer(final int
the PointerBuffer size, in number of pointers capacity)Creates a new PointerBuffer with the specified capacity. |
| public | PointerBuffer(final ByteBuffer
the source buffer source)Creates a new PointerBuffer using the specified ByteBuffer as its pointer data source. |
| Modifier and Type | Method and Description |
|---|---|
| public static PointerBuffer | Returns: The new pointer bufferThe new buffer's capacity, in pointers capacity)Allocates a new pointer buffer. |
| public PointerBuffer | Returns: The new, read-only pointer bufferCreates a new, read-only pointer buffer that shares this buffer's content. |
| public final int | |
| private static void | |
| private static void | |
| public final PointerBuffer | |
| public PointerBuffer | |
| public int | Returns: A negative integer, zero, or a positive integer as this buffer is less than, equal to, or greater than the given bufferthe object to be compared. o)Implements java. |
| public PointerBuffer | Returns: The new pointer bufferCreates a new pointer buffer that shares this buffer's content. |
| public boolean | Returns: true if, and only if, this buffer is equal to the given objectThe object to which this buffer is to be compared ob)Overrides java. |
| public final PointerBuffer | |
| public long | |
| public long | Returns: The long at the given indexThe index from which the long will be read index)Absolute get method. |
| public PointerBuffer | Returns: This bufferThe array into which longs are to be written dst, int The offset within the array of the first long to be
written; must be non-negative and no larger than
dst.length offset, int The maximum number of longs to be written to the given
array; must be non-negative and no larger than
dst.length - offset length)Relative bulk get method. |
| public PointerBuffer | |
| public ByteBuffer | |
| public static int | Returns: The pointer size in bytesReturns the pointer size in bytes, based on the underlying architecture. |
| public int | Returns: The current hash code of this bufferOverrides java. |
| public final boolean | Returns: true if, and only if, there is at least one element remaining in this bufferTells whether there are any elements between the current position and the limit. |
| public static boolean | |
| public boolean | |
| public final int | |
| public final PointerBuffer | Returns: This bufferThe new limit value; must be non-negative
and no larger than this buffer's capacity newLimit)Sets this buffer's limit. |
| public final PointerBuffer | |
| protected PointerBuffer | Returns: A new PointerBuffer instanceThis method is used in slice and duplicate instead of normal object construction, so that subclasses can return themselves. |
| public ByteOrder | |
| public final int | |
| public final PointerBuffer | Returns: This bufferThe new position value; must be non-negative
and no larger than the current limit newPosition)Sets this buffer's position. |
| public final int | Returns: The position of this buffer in bytes.Returns this buffer's position, in bytes. |
| public PointerBuffer | |
| public PointerBuffer | |
| public static void | put(final ByteBuffer
the target ByteBuffer target, long the long value to be written l)Convenience put on a target ByteBuffer. |
| public PointerBuffer | Returns: This bufferThe index at which the long will be written index, long The long value to be written l)Absolute put method (optional operation). |
| public PointerBuffer | |
| public static void | put(final ByteBuffer
the target ByteBuffer target, int the index at which the long will be written index, long the long value to be written l)Convenience put on a target ByteBuffer. |
| public PointerBuffer | Returns: This bufferThe source buffer from which longs are to be read;
must not be this buffer src)Relative bulk put method (optional operation). |
| public PointerBuffer | Returns: This bufferThe array from which longs are to be read src, int The offset within the array of the first long to be read;
must be non-negative and no larger than array.length offset, int The number of longs to be read from the given array;
must be non-negative and no larger than
array.length - offset length)Relative bulk put method (optional operation). |
| public final PointerBuffer | |
| public final int | Returns: The number of elements remaining in this bufferReturns the number of elements between the current position and the limit. |
| public final int | Returns: The number of bytes remaining in this bufferReturns the number of bytes between the current position and the limit. |
| public final PointerBuffer | |
| public final PointerBuffer | |
| public PointerBuffer | Returns: The new pointer bufferCreates a new pointer buffer whose content is a shared subsequence of this buffer's content. |
| public String | Returns: A summary stringOverrides java. |
| is64Bit | back to summary |
|---|---|
| private static final boolean is64Bit | |
| pointers | back to summary |
|---|---|
| protected final ByteBuffer pointers | |
| view | back to summary |
|---|---|
| protected final Buffer view | |
| view32 | back to summary |
|---|---|
| protected final IntBuffer view32 | |
| view64 | back to summary |
|---|---|
| protected final LongBuffer view64 | |
| PointerBuffer | back to summary |
|---|---|
| public PointerBuffer(final int capacity) Creates a new PointerBuffer with the specified capacity.
| |
| PointerBuffer | back to summary |
|---|---|
| public PointerBuffer(final ByteBuffer source) Creates a new PointerBuffer using the specified ByteBuffer as its pointer data source. This is useful for users that do their own memory management over a big ByteBuffer, instead of allocating many small ones.
| |
| allocateDirect | back to summary |
|---|---|
| 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.
| |
| asReadOnlyBuffer | back to summary |
|---|---|
| public PointerBuffer asReadOnlyBuffer() Creates a new, read-only 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; the new buffer itself, however, will be read-only and will not allow the shared content to be modified. 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.
If this buffer is itself read-only then this method behaves in
exactly the same way as the
| |
| capacity | back to summary |
|---|---|
| public final int capacity() Returns this buffer's capacity.
| |
| checkBounds | back to summary |
|---|---|
| private static void checkBounds(int off, int len, int size) | |
| checkSource | back to summary |
|---|---|
| private static void checkSource(final ByteBuffer source) | |
| clear | back to summary |
|---|---|
| public final 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.
| |
| compact | back to summary |
|---|---|
| public PointerBuffer compact() Compacts this buffer (optional operation).
The longs between the buffer's current position and its limit, if any, are copied to the beginning of the buffer. That is, the long at index p = position() is copied to index zero, the long at index p + 1 is copied to index one, and so forth until the long 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 longs copied, rather than to zero, so that an invocation of this method can be followed immediately by an invocation of another relative put method.
| |
| compareTo | back to summary |
|---|---|
| public int compareTo(Object o) Implements java. 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.
| |
| duplicate | back to summary |
|---|---|
| public 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. 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.
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object ob) Overrides java. Tells whether or not this buffer is equal to another object.
Two pointer buffers are equal if, and only if,
A pointer buffer is not equal to any other type of object.
| |
| flip | back to summary |
|---|---|
| public final 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
| |
| get | back to summary |
|---|---|
| public long get() Relative get method. Reads the long at this buffer's current position, and then increments the position.
| |
| get | back to summary |
|---|---|
| public long get(int index) Absolute get method. Reads the long at the given index.
| |
| get | back to summary |
|---|---|
| public PointerBuffer get(long[] dst, int offset, int length) Relative bulk get method.
This method transfers longs from this buffer into the given
destination array. If there are fewer longs remaining in the
buffer than are required to satisfy the request, that is, if
length > remaining(), then no
longs are transferred and a
Otherwise, this method copies length longs from this buffer into the given array, starting at the current position of this buffer and at the given 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 longs in this buffer and it is potentially much more efficient.
| |
| get | back to summary |
|---|---|
| public PointerBuffer get(long[] dst) Relative bulk get method.
This method transfers longs from this buffer into the given 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)
| |
| getBuffer | back to summary |
|---|---|
| public ByteBuffer getBuffer() Returns the ByteBuffer that backs this PointerBuffer.
| |
| getPointerSize | back to summary |
|---|---|
| public static int getPointerSize() Returns the pointer size in bytes, based on the underlying architecture.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. 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.
| |
| hasRemaining | back to summary |
|---|---|
| public final boolean hasRemaining() Tells whether there are any elements between the current position and the limit.
| |
| is64Bit | back to summary |
|---|---|
| public static boolean is64Bit() Returns true if the underlying architecture is 64bit. | |
| isReadOnly | back to summary |
|---|---|
| public boolean isReadOnly() | |
| limit | back to summary |
|---|---|
| public final int limit() Returns this buffer's limit.
| |
| limit | back to summary |
|---|---|
| public final 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.
| |
| mark | back to summary |
|---|---|
| public final PointerBuffer mark() Sets this buffer's mark at its position.
| |
| newInstance | back to summary |
|---|---|
| protected PointerBuffer newInstance(final ByteBuffer source) This method is used in slice and duplicate instead of normal object construction, so that subclasses can return themselves.
| |
| order | back to summary |
|---|---|
| public ByteOrder order() Retrieves this buffer's byte order.
The byte order of a pointer buffer created by allocation or by
wrapping an existing long array is the
| |
| position | back to summary |
|---|---|
| public final int position() Returns this buffer's position.
| |
| position | back to summary |
|---|---|
| public final PointerBuffer position(int newPosition) Sets this buffer's position. If the mark is defined and larger than the new position then it is discarded.
| |
| positionByte | back to summary |
|---|---|
| public final int positionByte() Returns this buffer's position, in bytes.
| |
| put | back to summary |
|---|---|
| public PointerBuffer put(long l) Relative put method (optional operation).
Writes the given long into this buffer at the current position, and then increments the position.
| |
| put | back to summary |
|---|---|
| public PointerBuffer put(final PointerWrapper pointer) Convenience put that accepts PointerWrapper objects.
| |
| put | back to summary |
|---|---|
| public static void put(final ByteBuffer target, long l) Convenience put on a target ByteBuffer.
| |
| put | back to summary |
|---|---|
| public PointerBuffer put(int index, long l) Absolute put method (optional operation).
Writes the given long into this buffer at the given index.
| |
| put | back to summary |
|---|---|
| public PointerBuffer put(int index, PointerWrapper pointer) Convenience put that accepts PointerWrapper objects.
| |
| put | back to summary |
|---|---|
| public static void put(final ByteBuffer target, int index, long l) Convenience put on a target ByteBuffer.
| |
| put | back to summary |
|---|---|
| public PointerBuffer put(PointerBuffer src) Relative bulk put method (optional operation).
This method transfers the longs remaining in the given source
buffer into this buffer. If there are more longs remaining in the
source buffer than in this buffer, that is, if
src.remaining() > remaining(),
then no longs are transferred and a
Otherwise, this method copies n = src.remaining() longs from the given 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.
| |
| put | back to summary |
|---|---|
| public PointerBuffer put(long[] src, int offset, int length) Relative bulk put method (optional operation).
This method transfers longs into this buffer from the given
source array. If there are more longs to be copied from the array
than remain in this buffer, that is, if
length > remaining(), then no
longs are transferred and a
Otherwise, this method copies length longs from the given array into this buffer, starting at the given 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.
| |
| put | back to summary |
|---|---|
| public final PointerBuffer put(long[] src) Relative bulk put method (optional operation).
This method transfers the entire content of the given source long 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)
| |
| remaining | back to summary |
|---|---|
| public final int remaining() Returns the number of elements between the current position and the limit.
| |
| remainingByte | back to summary |
|---|---|
| public final int remainingByte() Returns the number of bytes between the current position and the limit.
| |
| reset | back to summary |
|---|---|
| public final PointerBuffer reset() Resets this buffer's position to the previously-marked position.
Invoking this method neither changes nor discards the mark's value.
| |
| rewind | back to summary |
|---|---|
| public final 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
| |
| slice | back to summary |
|---|---|
| public 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 longs 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.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns a string summarizing the state of this buffer.
| |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public PointerBuffer | asReadOnlyBuffer()
Overrides org. |
| public PointerBuffer | |
| public boolean | |
| protected PointerBuffer | newInstance(final ByteBuffer source)
Overrides org. |
| public PointerBuffer | put(final long
The long to be written l)Overrides org. |
| public PointerBuffer | put(final int
The index at which the long will be written index, final long The long value to be written l)Overrides org. |
| public PointerBuffer | put(final PointerBuffer
The source buffer from which longs are to be read;
must not be this buffer src)Overrides org. |
| public PointerBuffer | put(final long[]
The array from which longs are to be read src, final int The offset within the array of the first long to be read;
must be non-negative and no larger than array.length offset, final int The number of longs to be read from the given array;
must be non-negative and no larger than
array.length - offset length)Overrides org. |
| PointerBufferR | back to summary |
|---|---|
| pack-priv PointerBufferR(final ByteBuffer source) | |
| asReadOnlyBuffer | back to summary |
|---|---|
| public PointerBuffer asReadOnlyBuffer() Overrides org. Doc from org. Creates a new, read-only 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; the new buffer itself, however, will be read-only and will not allow the shared content to be modified. 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.
If this buffer is itself read-only then this method behaves in
exactly the same way as the
| |
| compact | back to summary |
|---|---|
| public PointerBuffer compact() Overrides org. Doc from org. Compacts this buffer (optional operation).
The longs between the buffer's current position and its limit, if any, are copied to the beginning of the buffer. That is, the long at index p = position() is copied to index zero, the long at index p + 1 is copied to index one, and so forth until the long 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 longs copied, rather than to zero, so that an invocation of this method can be followed immediately by an invocation of another relative put method.
| |
| isReadOnly | back to summary |
|---|---|
| public boolean isReadOnly() Overrides org. | |
| newInstance | back to summary |
|---|---|
| protected PointerBuffer newInstance(final ByteBuffer source) Overrides org. Doc from org. This method is used in slice and duplicate instead of normal object construction, so that subclasses can return themselves.
| |
| put | back to summary |
|---|---|
| public PointerBuffer put(final long l) Overrides org. Doc from org. Relative put method (optional operation).
Writes the given long into this buffer at the current position, and then increments the position.
| |
| put | back to summary |
|---|---|
| public PointerBuffer put(final int index, final long l) Overrides org. Doc from org. Absolute put method (optional operation).
Writes the given long into this buffer at the given index.
| |
| put | back to summary |
|---|---|
| public PointerBuffer put(final PointerBuffer src) Overrides org. Doc from org. Relative bulk put method (optional operation).
This method transfers the longs remaining in the given source
buffer into this buffer. If there are more longs remaining in the
source buffer than in this buffer, that is, if
src.remaining() > remaining(),
then no longs are transferred and a
Otherwise, this method copies n = src.remaining() longs from the given 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.
| |
| put | back to summary |
|---|---|
| public PointerBuffer put(final long[] src, final int offset, final int length) Overrides org. Doc from org. Relative bulk put method (optional operation).
This method transfers longs into this buffer from the given
source array. If there are more longs to be copied from the array
than remain in this buffer, that is, if
length > remaining(), then no
longs are transferred and a
Otherwise, this method copies length longs from the given array into this buffer, starting at the given 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.
| |