|
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(java.lang.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. |
java.util.Iterator<E> |
iterator()
|
E |
last()
Returns the tail of this, or throws NoSuchElementException if this is empty. |
E |
remove(int i)
|
boolean |
remove(java.lang.Object x)
|
boolean |
removeAll(java.lang.Object x)
|
E |
removeFirst()
|
E |
removeLast()
|
void |
set(int i,
E o)
|
int |
size()
Same as getSize(). |
java.lang.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 java.lang.IndexOutOfBoundsException
java.lang.IndexOutOfBoundsException
public void set(int i,
E o)
throws java.lang.IndexOutOfBoundsException
java.lang.IndexOutOfBoundsExceptionpublic E add(E x)
public E addFirst(E x)
public E addLast(E x)
public boolean contains(java.lang.Object x)
public E first()
throws java.util.NoSuchElementException
java.util.NoSuchElementException
public E last()
throws java.util.NoSuchElementException
java.util.NoSuchElementException
public E removeFirst()
throws java.util.NoSuchElementException
java.util.NoSuchElementException
public E removeLast()
throws java.util.NoSuchElementException
java.util.NoSuchElementException
public E remove(int i)
throws java.lang.IndexOutOfBoundsException
java.lang.IndexOutOfBoundsExceptionpublic boolean remove(java.lang.Object x)
public boolean removeAll(java.lang.Object x)
public void clear()
public java.util.Iterator<E> iterator()
iterator in interface java.lang.Iterable<E>
public Buffer<E> clone()
throws java.lang.CloneNotSupportedException
clone in class java.lang.Objectjava.lang.CloneNotSupportedExceptionpublic java.lang.String toString()
toString in class java.lang.Object
|
LimeWire collection component api | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||