|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgoldman.collection.positional.Buffer<E>
public class Buffer<E>
For many applications, elements need only be added or removed from the front or back end of the collection. Data structures designed for such settings can gain efficiency by limiting access to the ends. The buffer is the most general ADT for this category. A buffer allows the user to insert or remove an element from either end of the collection.
Constructor Summary | |
---|---|
Buffer()
Creates an unbounded, untracked buffer with a default initial capacity |
|
Buffer(int capacity)
Creates an unbounded, untracked buffer with the given initial capacity |
|
Buffer(int capacity,
boolean bounded)
Creates an untracked buffer with the specified parameters |
|
Buffer(int capacity,
boolean bounded,
boolean tracked)
Creates a buffer satisfying the specification of the given parameters |
Method Summary | |
---|---|
void |
addFirst(E element)
|
void |
addLast(E element)
|
void |
clear()
Removes all elements from the buffer. |
boolean |
contains(E value)
|
E |
getFirst()
|
E |
getLast()
|
int |
getSize()
|
boolean |
isEmpty()
|
PositionalCollectionLocator<E> |
iterator()
Creates a new locator that starts just before the first item in the buffer. |
E |
removeFirst()
Removes the first element in the buffer, |
E |
removeLast()
Removes the last element in the buffer |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Buffer(int capacity, boolean bounded, boolean tracked)
capacity
- the initial capacity for the underlying positional collectionbounded
- a boolean which is true if and only if the buffer should be bounded
at the given capacitytracked
- a boolean which is true if and only if the buffer should support a trackerpublic Buffer()
public Buffer(int capacity)
capacity
- the initial capacity for the underlying positional collectionpublic Buffer(int capacity, boolean bounded)
capacity
- the initial capacity for the underlying positional collectionbounded
- a boolean which is true if and only if the buffer should be boundedMethod Detail |
---|
public boolean isEmpty()
public int getSize()
public String toString()
toString
in class Object
public boolean contains(E value)
value
- the target
public E getFirst()
public E getLast()
public void addFirst(E element)
element
- the element that is to be inserted at the
front of the buffer.
AtCapacityException
- a bounded buffer is fullpublic void addLast(E element)
element
- the element that is to be inserted at the end
of the buffer.
AtCapacityException
- a bounded buffer is fullpublic E removeFirst()
NoSuchElementException
- the buffer is emptypublic E removeLast()
NoSuchElementException
- the buffer is emptypublic void clear()
public PositionalCollectionLocator<E> iterator()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |