public class FastByteBuffer extends Object
byte buffer.| 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.public FastByteBuffer append(byte[] array, int off, int len)
byte array to buffer.array - the arrayoff - the offlen - the lenpublic FastByteBuffer append(byte[] array)
byte array to buffer.array - the arraypublic FastByteBuffer append(byte element)
byte to buffer.element - the elementpublic FastByteBuffer append(FastByteBuffer buff)
buff - the buffpublic 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.index - the indexpublic void clear()
public byte[] toArray()
byte array from buffered content.public byte[] toArray(int start,
int len)
byte subarray from buffered content.start - the startlen - the lenpublic byte get(int index)
byte element at given index.index - the indexCopyright © 2016 utils4j. All Rights Reserved.