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