public class FastByteBuffer extends Object implements IoBuffer
| Modifier and Type | Field and Description |
|---|---|
static long |
SIZE_OF_BOOLEAN |
static long |
SIZE_OF_BYTE |
static long |
SIZE_OF_CHAR |
static long |
SIZE_OF_DOUBLE |
static long |
SIZE_OF_FLOAT |
static long |
SIZE_OF_INT |
static long |
SIZE_OF_LONG |
static long |
SIZE_OF_SHORT |
| Constructor and Description |
|---|
FastByteBuffer()
construct new FastByteBuffer
|
FastByteBuffer(byte[] buffer,
int limit)
construct new FastByteBuffer
|
FastByteBuffer(int size)
construct new FastByteBuffer
|
| Modifier and Type | Method and Description |
|---|---|
int |
capacity() |
IoBuffer |
clear()
Clears this buffer.
|
static void |
copyMemory(Object srcBase,
long srcOffset,
Object destBase,
long destOffset,
long nBytes) |
byte[] |
elements() |
IoBuffer |
ensureAdditionalCapacity(long capacity) |
IoBuffer |
ensureCapacity(long newCapacity) |
IoBuffer |
forceCapacity(long length,
long preserve)
Forces FastByteBUffer to contain the given number of entries, preserving just a part of the array.
|
boolean |
getBoolean() |
boolean[] |
getBooleanArray(boolean[] dst,
long offset,
int length) |
byte |
getByte() |
byte[] |
getByteArray(byte[] dst,
long offset,
int length) |
char |
getChar() |
char[] |
getCharArray(char[] dst,
long offset,
int length) |
double |
getDouble() |
double[] |
getDoubleArray(double[] dst,
long offset,
int length) |
float |
getFloat() |
float[] |
getFloatArray(float[] dst,
long offset,
int length) |
int |
getInt() |
int[] |
getIntArray(int[] dst,
long offset,
int length) |
long |
getLong() |
long[] |
getLongArray(long[] dst,
long offset,
int length) |
short |
getShort() |
short[] |
getShortArray(short[] dst,
long offset,
int length) |
String |
getString() |
String[] |
getStringArray(String[] dst,
long offset,
int length) |
boolean |
hasRemaining() |
boolean |
isReadOnly() |
long |
limit() |
IoBuffer |
limit(int newLimit)
Sets this buffer's limit.
|
ReadWriteLock |
lock()
For efficiency/performance reasons the buffer implementation is not required to safe-guard each put/get method
independently.
|
long |
position() |
IoBuffer |
position(long newPosition)
Sets this buffer's position.
|
IoBuffer |
putBoolean(boolean value) |
IoBuffer |
putBooleanArray(boolean[] values,
long offset,
int nToCopy) |
IoBuffer |
putByte(byte value) |
IoBuffer |
putByteArray(byte[] values,
long offset,
int nToCopy) |
IoBuffer |
putChar(char value) |
IoBuffer |
putCharArray(char[] values,
long offset,
int nToCopy) |
IoBuffer |
putDouble(double value) |
IoBuffer |
putDoubleArray(double[] values,
long offset,
int nToCopy) |
IoBuffer |
putFloat(float value) |
IoBuffer |
putFloatArray(float[] values,
long offset,
int nToCopy) |
IoBuffer |
putInt(int value) |
IoBuffer |
putIntArray(int[] values,
long offset,
int nToCopy) |
IoBuffer |
putLong(long value) |
IoBuffer |
putLongArray(long[] values,
long offset,
int nToCopy) |
IoBuffer |
putShort(short value) |
IoBuffer |
putShortArray(short[] values,
long offset,
int nToCopy) |
IoBuffer |
putString(String string) |
IoBuffer |
putStringArray(String[] values,
long offset,
int nToCopy) |
long |
remaining() |
IoBuffer |
reset()
resets the buffer read/write position to zero
|
IoBuffer |
trim()
Trims the internal buffer array so that the capacity is equal to the size.
|
IoBuffer |
trim(int requestedCapacity)
Trims the internal buffer array if it is too large.
|
static FastByteBuffer |
wrap(byte[] byteArray)
Wraps a given byte array into FastByteBuffer
|
static FastByteBuffer |
wrap(byte[] byteArray,
int length)
Wraps a given byte array into FastByteBuffer
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetBooleanArray, getBooleanArray, getByteArray, getByteArray, getCharArray, getCharArray, getDoubleArray, getDoubleArray, getFloatArray, getFloatArray, getIntArray, getIntArray, getLongArray, getLongArray, getShortArray, getShortArray, getStringArray, getStringArray, putBooleanArray, putBooleanArray, putByteArray, putByteArray, putCharArray, putCharArray, putDoubleArray, putDoubleArray, putFloatArray, putFloatArray, putIntArray, putIntArray, putLongArray, putLongArray, putShortArray, putShortArray, putStringArray, putStringArraypublic static final long SIZE_OF_BOOLEAN
public static final long SIZE_OF_BYTE
public static final long SIZE_OF_SHORT
public static final long SIZE_OF_CHAR
public static final long SIZE_OF_INT
public static final long SIZE_OF_LONG
public static final long SIZE_OF_FLOAT
public static final long SIZE_OF_DOUBLE
public FastByteBuffer()
public FastByteBuffer(byte[] buffer,
int limit)
buffer - buffer to initialise/re-uselimit - position until buffer is filledpublic FastByteBuffer(int size)
size - initial capacity of the bufferpublic int capacity()
capacity in interface IoBufferHeader<IoBuffer>public IoBuffer clear()
IoBufferHeaderInvoke 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.
clear in interface IoBufferHeader<IoBuffer>public byte[] elements()
public IoBuffer ensureAdditionalCapacity(long capacity)
ensureAdditionalCapacity in interface IoBufferHeader<IoBuffer>public IoBuffer ensureCapacity(long newCapacity)
ensureCapacity in interface IoBufferHeader<IoBuffer>public IoBuffer forceCapacity(long length, long preserve)
forceCapacity in interface IoBufferHeader<IoBuffer>length - the new minimum length for this array.preserve - the number of elements of the old buffer that shall be preserved in case a new allocation is
necessary.public boolean getBoolean()
getBoolean in interface IoBufferpublic boolean[] getBooleanArray(boolean[] dst,
long offset,
int length)
getBooleanArray in interface IoBufferpublic byte[] getByteArray(byte[] dst,
long offset,
int length)
getByteArray in interface IoBufferpublic char[] getCharArray(char[] dst,
long offset,
int length)
getCharArray in interface IoBufferpublic double[] getDoubleArray(double[] dst,
long offset,
int length)
getDoubleArray in interface IoBufferpublic float[] getFloatArray(float[] dst,
long offset,
int length)
getFloatArray in interface IoBufferpublic int[] getIntArray(int[] dst,
long offset,
int length)
getIntArray in interface IoBufferpublic long[] getLongArray(long[] dst,
long offset,
int length)
getLongArray in interface IoBufferpublic short[] getShortArray(short[] dst,
long offset,
int length)
getShortArray in interface IoBufferpublic String[] getStringArray(String[] dst, long offset, int length)
getStringArray in interface IoBufferpublic boolean hasRemaining()
hasRemaining in interface IoBufferHeader<IoBuffer>true if, and only if, there is at least one element remaining in this bufferpublic boolean isReadOnly()
isReadOnly in interface IoBufferHeader<IoBuffer>true if, and only if, this buffer is read-onlypublic long limit()
limit in interface IoBufferHeader<IoBuffer>public IoBuffer limit(int newLimit)
IoBufferHeaderlimit in interface IoBufferHeader<IoBuffer>newLimit - the new limit value; must be non-negative and no larger than this buffer's capacitypublic ReadWriteLock lock()
IoBufferHeaderlock in interface IoBufferHeader<IoBuffer>public long position()
position in interface IoBufferHeader<IoBuffer>public IoBuffer position(long newPosition)
IoBufferHeaderposition in interface IoBufferHeader<IoBuffer>newPosition - the new position value; must be non-negative and no larger than the current limitpublic IoBuffer putBoolean(boolean value)
putBoolean in interface IoBufferpublic IoBuffer putBooleanArray(boolean[] values, long offset, int nToCopy)
putBooleanArray in interface IoBufferpublic IoBuffer putByteArray(byte[] values, long offset, int nToCopy)
putByteArray in interface IoBufferpublic IoBuffer putCharArray(char[] values, long offset, int nToCopy)
putCharArray in interface IoBufferpublic IoBuffer putDoubleArray(double[] values, long offset, int nToCopy)
putDoubleArray in interface IoBufferpublic IoBuffer putFloatArray(float[] values, long offset, int nToCopy)
putFloatArray in interface IoBufferpublic IoBuffer putIntArray(int[] values, long offset, int nToCopy)
putIntArray in interface IoBufferpublic IoBuffer putLongArray(long[] values, long offset, int nToCopy)
putLongArray in interface IoBufferpublic IoBuffer putShortArray(short[] values, long offset, int nToCopy)
putShortArray in interface IoBufferpublic IoBuffer putStringArray(String[] values, long offset, int nToCopy)
putStringArray in interface IoBufferpublic long remaining()
remaining in interface IoBufferHeader<IoBuffer>public IoBuffer reset()
IoBufferHeaderreset in interface IoBufferHeader<IoBuffer>public IoBuffer trim()
trim in interface IoBufferHeader<IoBuffer>ArrayList.trimToSize()public IoBuffer trim(int requestedCapacity)
n, this method does nothing. Otherwise, it trims the array length to the maximum between
requestedCapacity and capacity().
This method is useful when reusing FastBuffers. Clearing a list leaves the array length untouched. If you are reusing a list many times, you can call this method with a typical size to avoid keeping around a very large array just because of a few large transient lists.
trim in interface IoBufferHeader<IoBuffer>requestedCapacity - the threshold for the trimming.public static void copyMemory(Object srcBase, long srcOffset, Object destBase, long destOffset, long nBytes)
public static FastByteBuffer wrap(byte[] byteArray)
Note it is guaranteed that the type of the array returned by elements() will be the same.
byteArray - an array to wrap.public static FastByteBuffer wrap(byte[] byteArray, int length)
Note it is guaranteed that the type of the array returned by elements() will be the same.
byteArray - an array to wrap.length - the length of the resulting array list.Copyright © 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH. All rights reserved.