|
LimeWire Collection Component API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.limewire.collection.Buffer<E>
public class Buffer<E>
Provides a simple fixed-size double-ended queue, a circular buffer.
The fixed size is intentional for performance; use Buffer
when you want to use a fix amount of resources.
For a minimal amount of efficiency, the internal buffer is only
allocated on the first insertion or retrieval, allowing lots of
Buffers to be created that may not be used.
This class is not thread-safe.
| Field Summary | |
|---|---|
protected E[] |
buf
|
| Constructor Summary | |
|---|---|
Buffer(Buffer<? extends E> other)
"Copy constructor": constructs a new shallow copy of other. |
|
Buffer(int size)
|
|
| Method Summary | |
|---|---|
E |
add(E x)
Same as addFirst(x). |
E |
addFirst(E x)
|
E |
addLast(E x)
|
void |
clear()
|
Buffer<E> |
clone()
Returns a shallow copy of this, of type Buffer |
boolean |
contains(Object x)
Returns true if the input object x is in the buffer. |
protected E[] |
createArray(int size)
|
E |
first()
Returns the head of this, or throws NoSuchElementException if this is empty. |
E |
get(int i)
If i<0 or i>=getSize(), throws IndexOutOfBoundsException. |
int |
getCapacity()
Returns the number of elements that this can hold, i.e., the max size that was passed to the constructor. |
int |
getSize()
Returns the number of elements in this. |
protected void |
initialize()
Initializes the internal buf if necessary. |
boolean |
isEmpty()
Returns true if and only if this is empty. |
boolean |
isFull()
Returns true if and only if this is full, e.g., adding another element would force another out. |
Iterator<E> |
iterator()
|
E |
last()
Returns the tail of this, or throws NoSuchElementException if this is empty. |
E |
remove(int i)
|
boolean |
remove(Object x)
|
boolean |
removeAll(Object x)
|
E |
removeFirst()
|
E |
removeLast()
|
void |
set(int i,
E o)
|
int |
size()
Same as getSize(). |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected E[] buf
| Constructor Detail |
|---|
public Buffer(int size)
public Buffer(Buffer<? extends E> other)
| Method Detail |
|---|
protected E[] createArray(int size)
protected void initialize()
public boolean isEmpty()
public boolean isFull()
public final int size()
public int getSize()
public int getCapacity()
public E get(int i)
throws IndexOutOfBoundsException
IndexOutOfBoundsException
public void set(int i,
E o)
throws IndexOutOfBoundsException
IndexOutOfBoundsExceptionpublic E add(E x)
public E addFirst(E x)
public E addLast(E x)
public boolean contains(Object x)
public E first()
throws NoSuchElementException
NoSuchElementException
public E last()
throws NoSuchElementException
NoSuchElementException
public E removeFirst()
throws NoSuchElementException
NoSuchElementException
public E removeLast()
throws NoSuchElementException
NoSuchElementException
public E remove(int i)
throws IndexOutOfBoundsException
IndexOutOfBoundsExceptionpublic boolean remove(Object x)
public boolean removeAll(Object x)
public void clear()
public Iterator<E> iterator()
iterator in interface Iterable<E>
public Buffer<E> clone()
throws CloneNotSupportedException
clone in class ObjectCloneNotSupportedExceptionpublic String toString()
toString in class Object
|
LimeWire Collection Component API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||