public enum BufferUtils extends Enum<BufferUtils>
| Modifier and Type | Field and Description |
|---|---|
static ByteBuffer |
EMPTY_BUFFER
An empty, read-only
ByteBuffer which has
native order |
| Modifier and Type | Method and Description |
|---|---|
static ByteBuffer |
allocate(int capacity)
Allocates a new
ByteBuffer with the specified capacity. |
static ByteBuffer |
allocate(int capacity,
ByteOrder order)
Allocates a new
ByteBuffer with the specified capacity. |
static ByteBuffer |
asReadOnlyBuffer(ByteBuffer b)
Creates a new, read-only byte buffer that shares the specified buffer's
content, and preserves it's order.
|
static ByteBuffer |
copy(ByteBuffer b,
int fromIndex,
int toIndex)
Returns a copy of a range from the specified buffer.
|
static DoubleBuffer |
copy(DoubleBuffer b,
int fromIndex,
int toIndex)
Returns a copy of a range from the specified buffer.
|
static FloatBuffer |
copy(FloatBuffer b,
int fromIndex,
int toIndex)
Returns a copy of a range from the specified buffer.
|
static IntBuffer |
copy(IntBuffer b,
int fromIndex,
int toIndex)
Returns a copy of a range from the specified buffer.
|
static LongBuffer |
copy(LongBuffer b,
int fromIndex,
int toIndex)
Returns a copy of a range from the specified buffer.
|
static ShortBuffer |
copy(ShortBuffer b,
int fromIndex,
int toIndex)
Returns a copy of a range from the specified buffer.
|
static int |
deduplicate(ByteBuffer b,
int fromIndex,
int toIndex)
Deduplicates a range of the specified
ByteBuffer. |
static int |
deduplicate(DoubleBuffer b,
int fromIndex,
int toIndex)
Deduplicates a range of the specified
DoubleBuffer. |
static int |
deduplicate(FloatBuffer b,
int fromIndex,
int toIndex)
Deduplicates a range of the specified
FloatBuffer. |
static int |
deduplicate(IntBuffer b,
int fromIndex,
int toIndex)
Deduplicates a range of the specified
IntBuffer. |
static int |
deduplicate(LongBuffer b,
int fromIndex,
int toIndex)
Deduplicates a range of the specified
LongBuffer. |
static int |
deduplicate(ShortBuffer b,
int fromIndex,
int toIndex)
Deduplicates a range of the specified
ShortBuffer. |
static ByteBuffer |
duplicate(ByteBuffer b)
Duplicate a
ByteBuffer and preserve the order. |
static boolean |
isSorted(ByteBuffer b,
int fromIndex,
int toIndex)
Determines if the specified buffer is sorted inside the specified range.
|
static boolean |
isSorted(DoubleBuffer b,
int fromIndex,
int toIndex)
Determines if the specified buffer is sorted inside the specified range.
|
static boolean |
isSorted(FloatBuffer b,
int fromIndex,
int toIndex)
Determines if the specified buffer is sorted inside the specified range.
|
static boolean |
isSorted(IntBuffer b,
int fromIndex,
int toIndex)
Determines if the specified buffer is sorted inside the specified range.
|
static boolean |
isSorted(LongBuffer b,
int fromIndex,
int toIndex)
Determines if the specified buffer is sorted inside the specified range.
|
static boolean |
isSorted(ShortBuffer b,
int fromIndex,
int toIndex)
Determines if the specified buffer is sorted inside the specified range.
|
static boolean |
isSortedAndDistinct(ByteBuffer b,
int fromIndex,
int toIndex)
Determines if the specified buffer is sorted and distinct inside the
specified range.
|
static boolean |
isSortedAndDistinct(DoubleBuffer b,
int fromIndex,
int toIndex)
Determines if the specified buffer is sorted and distinct inside the
specified range.
|
static boolean |
isSortedAndDistinct(FloatBuffer b,
int fromIndex,
int toIndex)
Determines if the specified buffer is sorted and distinct inside the
specified range.
|
static boolean |
isSortedAndDistinct(IntBuffer b,
int fromIndex,
int toIndex)
Determines if the specified buffer is sorted and distinct inside the
specified range.
|
static boolean |
isSortedAndDistinct(LongBuffer b,
int fromIndex,
int toIndex)
Determines if the specified buffer is sorted and distinct inside the
specified range.
|
static boolean |
isSortedAndDistinct(ShortBuffer b,
int fromIndex,
int toIndex)
Determines if the specified buffer is sorted and distinct inside the
specified range.
|
static ByteBuffer |
slice(ByteBuffer b)
Slice a
ByteBuffer and preserve the order. |
static ByteBuffer |
slice(ByteBuffer b,
int fromIndex,
int toIndex)
Slice a range from the specified
ByteBuffer. |
static BufferUtils |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static BufferUtils[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final ByteBuffer EMPTY_BUFFER
ByteBuffer which has
native orderpublic static BufferUtils[] values()
for (BufferUtils c : BufferUtils.values()) System.out.println(c);
public static BufferUtils valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic static ByteBuffer allocate(int capacity)
ByteBuffer with the specified capacity. The buffer
will be direct if the tech.bitey.allocateDirect system property is
set to "true", and will have native order.capacity - the new buffer's capacity, in bytesByteBufferpublic static ByteBuffer allocate(int capacity, ByteOrder order)
ByteBuffer with the specified capacity. The buffer
will be direct if the tech.bitey.allocateDirect system property is
set to "true", and will have the specified ByteOrder.capacity - the new buffer's capacity, in bytesorder - the ByteOrderByteBufferpublic static ByteBuffer duplicate(ByteBuffer b)
ByteBuffer and preserve the order. Equivalent to:
b.duplicate().order(b.order())
b - - the buffer to be duplicatedByteBuffer.duplicate(),
ByteBuffer.order()public static ByteBuffer slice(ByteBuffer b)
ByteBuffer and preserve the order. Equivalent to:
b.slice().order(b.order())
b - - the buffer to be slicedByteBuffer.slice(),
ByteBuffer.order()public static ByteBuffer asReadOnlyBuffer(ByteBuffer b)
b.asReadOnlyBuffer().order(b.order())
b - - the buffer to be made read-onlyByteBuffer.asReadOnlyBuffer(),
ByteBuffer.order()public static ByteBuffer slice(ByteBuffer b, int fromIndex, int toIndex)
ByteBuffer. The buffer's order is
preserved.b - - the buffer to be slicedfromIndex - - the index of the first element in the range (inclusive)toIndex - - the index of the last element in the range (exclusive)IllegalArgumentException - if fromIndex > toIndexIndexOutOfBoundsException - if
fromIndex < 0 or toIndex > b.capacity()ByteBuffer.slice(),
ByteBuffer.order()public static boolean isSorted(IntBuffer b, int fromIndex, int toIndex)
buffer[i] <= buffer[i + 1] for all elements in the range. A range
of length zero or one is considered sorted.b - - the buffer to be checkedfromIndex - - the index of the first element (inclusive) to be checkedtoIndex - - the index of the last element (exclusive) to be checkedIllegalArgumentException - if fromIndex > toIndexIndexOutOfBoundsException - if
fromIndex < 0 or toIndex > b.capacity()public static boolean isSortedAndDistinct(IntBuffer b, int fromIndex, int toIndex)
buffer[i] < buffer[i + 1] for all elements
in the range. A range of length zero or one is considered sorted and
distinct.b - - the buffer to be checkedfromIndex - - the index of the first element (inclusive) to be checkedtoIndex - - the index of the last element (exclusive) to be checkedIllegalArgumentException - if fromIndex > toIndexIndexOutOfBoundsException - if
fromIndex < 0 or toIndex > b.capacity()public static boolean isSorted(LongBuffer b, int fromIndex, int toIndex)
buffer[i] <= buffer[i + 1] for all elements in the range. A range
of length zero or one is considered sorted.b - - the buffer to be checkedfromIndex - - the index of the first element (inclusive) to be checkedtoIndex - - the index of the last element (exclusive) to be checkedIllegalArgumentException - if fromIndex > toIndexIndexOutOfBoundsException - if
fromIndex < 0 or toIndex > b.capacity()public static boolean isSortedAndDistinct(LongBuffer b, int fromIndex, int toIndex)
buffer[i] < buffer[i + 1] for all elements
in the range. A range of length zero or one is considered sorted and
distinct.b - - the buffer to be checkedfromIndex - - the index of the first element (inclusive) to be checkedtoIndex - - the index of the last element (exclusive) to be checkedIllegalArgumentException - if fromIndex > toIndexIndexOutOfBoundsException - if
fromIndex < 0 or toIndex > b.capacity()public static boolean isSorted(ByteBuffer b, int fromIndex, int toIndex)
buffer[i] <= buffer[i + 1] for all elements in the range. A range
of length zero or one is considered sorted.b - - the buffer to be checkedfromIndex - - the index of the first element (inclusive) to be checkedtoIndex - - the index of the last element (exclusive) to be checkedIllegalArgumentException - if fromIndex > toIndexIndexOutOfBoundsException - if
fromIndex < 0 or toIndex > b.capacity()public static boolean isSortedAndDistinct(ByteBuffer b, int fromIndex, int toIndex)
buffer[i] < buffer[i + 1] for all elements
in the range. A range of length zero or one is considered sorted and
distinct.b - - the buffer to be checkedfromIndex - - the index of the first element (inclusive) to be checkedtoIndex - - the index of the last element (exclusive) to be checkedIllegalArgumentException - if fromIndex > toIndexIndexOutOfBoundsException - if
fromIndex < 0 or toIndex > b.capacity()public static boolean isSorted(ShortBuffer b, int fromIndex, int toIndex)
buffer[i] <= buffer[i + 1] for all elements in the range. A range
of length zero or one is considered sorted.b - - the buffer to be checkedfromIndex - - the index of the first element (inclusive) to be checkedtoIndex - - the index of the last element (exclusive) to be checkedIllegalArgumentException - if fromIndex > toIndexIndexOutOfBoundsException - if
fromIndex < 0 or toIndex > b.capacity()public static boolean isSortedAndDistinct(ShortBuffer b, int fromIndex, int toIndex)
buffer[i] < buffer[i + 1] for all elements
in the range. A range of length zero or one is considered sorted and
distinct.b - - the buffer to be checkedfromIndex - - the index of the first element (inclusive) to be checkedtoIndex - - the index of the last element (exclusive) to be checkedIllegalArgumentException - if fromIndex > toIndexIndexOutOfBoundsException - if
fromIndex < 0 or toIndex > b.capacity()public static boolean isSorted(FloatBuffer b, int fromIndex, int toIndex)
buffer[i] <= buffer[i + 1] for all elements in the range. A range
of length zero or one is considered sorted. The comparison of two values is
consistent with Float.compareTo(Float).b - - the buffer to be checkedfromIndex - - the index of the first element (inclusive) to be checkedtoIndex - - the index of the last element (exclusive) to be checkedIllegalArgumentException - if fromIndex > toIndexIndexOutOfBoundsException - if
fromIndex < 0 or toIndex > b.capacity()public static boolean isSortedAndDistinct(FloatBuffer b, int fromIndex, int toIndex)
buffer[i] < buffer[i + 1] for all elements
in the range. A range of length zero or one is considered sorted and
distinct. The comparison of two values is consistent with
Float.compareTo(Float).b - - the buffer to be checkedfromIndex - - the index of the first element (inclusive) to be checkedtoIndex - - the index of the last element (exclusive) to be checkedIllegalArgumentException - if fromIndex > toIndexIndexOutOfBoundsException - if
fromIndex < 0 or toIndex > b.capacity()public static boolean isSorted(DoubleBuffer b, int fromIndex, int toIndex)
buffer[i] <= buffer[i + 1] for all elements in the range. A range
of length zero or one is considered sorted. The comparison of two values is
consistent with Double.compareTo(Double).b - - the buffer to be checkedfromIndex - - the index of the first element (inclusive) to be checkedtoIndex - - the index of the last element (exclusive) to be checkedIllegalArgumentException - if fromIndex > toIndexIndexOutOfBoundsException - if
fromIndex < 0 or toIndex > b.capacity()public static boolean isSortedAndDistinct(DoubleBuffer b, int fromIndex, int toIndex)
buffer[i] < buffer[i + 1] for all elements
in the range. A range of length zero or one is considered sorted and
distinct. The comparison of two values is consistent with
Double.compareTo(Double).b - - the buffer to be checkedfromIndex - - the index of the first element (inclusive) to be checkedtoIndex - - the index of the last element (exclusive) to be checkedIllegalArgumentException - if fromIndex > toIndexIndexOutOfBoundsException - if
fromIndex < 0 or toIndex > b.capacity()public static ByteBuffer copy(ByteBuffer b, int fromIndex, int toIndex)
b - - the buffer to be checkedfromIndex - - the index of the first element (inclusive) to be checkedtoIndex - - the index of the last element (exclusive) to be checkedIllegalArgumentException - if fromIndex > toIndexIndexOutOfBoundsException - if
fromIndex < 0 or toIndex > b.capacity()public static IntBuffer copy(IntBuffer b, int fromIndex, int toIndex)
b - - the buffer to be checkedfromIndex - - the index of the first element (inclusive) to be checkedtoIndex - - the index of the last element (exclusive) to be checkedIllegalArgumentException - if fromIndex > toIndexIndexOutOfBoundsException - if
fromIndex < 0 or toIndex > b.capacity()public static LongBuffer copy(LongBuffer b, int fromIndex, int toIndex)
b - - the buffer to be checkedfromIndex - - the index of the first element (inclusive) to be checkedtoIndex - - the index of the last element (exclusive) to be checkedIllegalArgumentException - if fromIndex > toIndexIndexOutOfBoundsException - if
fromIndex < 0 or toIndex > b.capacity()public static ShortBuffer copy(ShortBuffer b, int fromIndex, int toIndex)
b - - the buffer to be checkedfromIndex - - the index of the first element (inclusive) to be checkedtoIndex - - the index of the last element (exclusive) to be checkedIllegalArgumentException - if fromIndex > toIndexIndexOutOfBoundsException - if
fromIndex < 0 or toIndex > b.capacity()public static FloatBuffer copy(FloatBuffer b, int fromIndex, int toIndex)
b - - the buffer to be checkedfromIndex - - the index of the first element (inclusive) to be checkedtoIndex - - the index of the last element (exclusive) to be checkedIllegalArgumentException - if fromIndex > toIndexIndexOutOfBoundsException - if
fromIndex < 0 or toIndex > b.capacity()public static DoubleBuffer copy(DoubleBuffer b, int fromIndex, int toIndex)
b - - the buffer to be checkedfromIndex - - the index of the first element (inclusive) to be checkedtoIndex - - the index of the last element (exclusive) to be checkedIllegalArgumentException - if fromIndex > toIndexIndexOutOfBoundsException - if
fromIndex < 0 or toIndex > b.capacity()public static int deduplicate(IntBuffer b, int fromIndex, int toIndex)
IntBuffer. The range must be
sorted in ascending order prior to making this call. If it is not sorted, the
results are undefined.
This method is useful as a post-processing step after a sort on a buffer which contains duplicate elements.
b - the buffer to be deduplicatedfromIndex - - the index of the first element (inclusive) to be
deduplicatedtoIndex - - the index of the last element (exclusive) to be
deduplicatedIllegalArgumentException - if fromIndex > toIndexIndexOutOfBoundsException - if
fromIndex < 0 or toIndex > b.capacity()public static int deduplicate(LongBuffer b, int fromIndex, int toIndex)
LongBuffer. The range must be
sorted in ascending order prior to making this call. If it is not sorted, the
results are undefined.
This method is useful as a post-processing step after a sort on a buffer which contains duplicate elements.
b - the buffer to be deduplicatedfromIndex - - the index of the first element (inclusive) to be
deduplicatedtoIndex - - the index of the last element (exclusive) to be
deduplicatedIllegalArgumentException - if fromIndex > toIndexIndexOutOfBoundsException - if
fromIndex < 0 or toIndex > b.capacity()public static int deduplicate(ShortBuffer b, int fromIndex, int toIndex)
ShortBuffer. The range must be
sorted in ascending order prior to making this call. If it is not sorted, the
results are undefined.
This method is useful as a post-processing step after a sort on a buffer which contains duplicate elements.
b - the buffer to be deduplicatedfromIndex - - the index of the first element (inclusive) to be
deduplicatedtoIndex - - the index of the last element (exclusive) to be
deduplicatedIllegalArgumentException - if fromIndex > toIndexIndexOutOfBoundsException - if
fromIndex < 0 or toIndex > b.capacity()public static int deduplicate(ByteBuffer b, int fromIndex, int toIndex)
ByteBuffer. The range must be
sorted in ascending order prior to making this call. If it is not sorted, the
results are undefined.
This method is useful as a post-processing step after a sort on a buffer which contains duplicate elements.
b - the buffer to be deduplicatedfromIndex - - the index of the first element (inclusive) to be
deduplicatedtoIndex - - the index of the last element (exclusive) to be
deduplicatedIllegalArgumentException - if fromIndex > toIndexIndexOutOfBoundsException - if
fromIndex < 0 or toIndex > b.capacity()public static int deduplicate(FloatBuffer b, int fromIndex, int toIndex)
FloatBuffer. The range must be
sorted in ascending order prior to making this call. If it is not sorted, the
results are undefined. This method considers all NaN values to be equivalent
and equal.
This method is useful as a post-processing step after a sort on a buffer which contains duplicate elements.
b - the buffer to be deduplicatedfromIndex - - the index of the first element (inclusive) to be
deduplicatedtoIndex - - the index of the last element (exclusive) to be
deduplicatedIllegalArgumentException - if fromIndex > toIndexIndexOutOfBoundsException - if
fromIndex < 0 or toIndex > b.capacity()public static int deduplicate(DoubleBuffer b, int fromIndex, int toIndex)
DoubleBuffer. The range must be
sorted in ascending order prior to making this call. If it is not sorted, the
results are undefined. This method considers all NaN values to be equivalent
and equal.
This method is useful as a post-processing step after a sort on a buffer which contains duplicate elements.
b - the buffer to be deduplicatedfromIndex - - the index of the first element (inclusive) to be
deduplicatedtoIndex - - the index of the last element (exclusive) to be
deduplicatedIllegalArgumentException - if fromIndex > toIndexIndexOutOfBoundsException - if
fromIndex < 0 or toIndex > b.capacity()Copyright © 2020. All rights reserved.