public class FastByteBuffer
extends java.lang.Object
byte
buffer.
This buffer implementation does not store all data
in single array, but in array of chunks.Constructor and Description |
---|
FastByteBuffer()
Creates a new
byte buffer. |
FastByteBuffer(int size)
Creates a new
byte buffer, with a buffer capacity of
the specified size, in bytes. |
Modifier and Type | Method and Description |
---|---|
FastByteBuffer |
append(byte element)
Appends single
byte to buffer. |
FastByteBuffer |
append(byte[] array)
Appends
byte array to buffer. |
FastByteBuffer |
append(byte[] array,
int off,
int len)
Appends
byte array to buffer. |
FastByteBuffer |
append(FastByteBuffer buff)
Appends another fast buffer to this one.
|
byte[] |
array(int index)
Returns
byte inner array chunk at given index. |
void |
clear()
Resets the buffer content.
|
byte |
get(int index)
Returns
byte element at given index. |
int |
index()
Returns current index of inner
byte array chunk. |
boolean |
isEmpty()
Tests if this buffer has no elements.
|
int |
offset()
Returns the offset of last used element in current inner array chunk.
|
int |
size()
Returns buffer size.
|
byte[] |
toArray()
Creates
byte array from buffered content. |
byte[] |
toArray(int start,
int len)
Creates
byte subarray from buffered content. |
public FastByteBuffer()
byte
buffer. The buffer capacity is
initially 1024 bytes, though its size increases if necessary.public FastByteBuffer(int size)
byte
buffer, with a buffer capacity of
the specified size, in bytes.size
- the initial size.java.lang.IllegalArgumentException
- if size is negative.public FastByteBuffer append(byte[] array, int off, int len)
byte
array to buffer.public FastByteBuffer append(byte[] array)
byte
array to buffer.public FastByteBuffer append(byte element)
byte
to buffer.public FastByteBuffer append(FastByteBuffer buff)
public int size()
public boolean isEmpty()
public int index()
byte
array chunk.
Represents the index of last used inner array chunk.public int offset()
public byte[] array(int index)
byte
inner array chunk at given index.
May be used for iterating inner chunks in fast manner.public void clear()
public byte[] toArray()
byte
array from buffered content.public byte[] toArray(int start, int len)
byte
subarray from buffered content.public byte get(int index)
byte
element at given index.Copyright © 2003-present Jodd Team