|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection<E>
org.apache.commons.collections4.queue.CircularFifoQueue<E>
public class CircularFifoQueue<E>
CircularFifoQueue is a first-in first-out queue with a fixed size that replaces its oldest element if full.
The removal order of a CircularFifoQueue
is based on the
insertion order; elements are removed in the same order in which they
were added. The iteration order is the same as the removal order.
The add(Object)
, remove()
, peek()
, poll()
,
offer(Object)
operations all perform in constant time.
All other operations perform in linear time or worse.
This queue prevents null objects from being added.
Constructor Summary | |
---|---|
CircularFifoQueue()
Constructor that creates a queue with the default size of 32. |
|
CircularFifoQueue(Collection<E> coll)
Constructor that creates a queue from the specified collection. |
|
CircularFifoQueue(int size)
Constructor that creates a queue with the specified size. |
Method Summary | |
---|---|
boolean |
add(E element)
Adds the given element to this queue. |
void |
clear()
Clears this queue. |
E |
element()
|
E |
get(int index)
Returns the element at the specified position in this queue. |
boolean |
isEmpty()
Returns true if this queue is empty; false otherwise. |
boolean |
isFull()
Returns true if this collection is full and no new elements can be added. |
Iterator<E> |
iterator()
Returns an iterator over this queue's elements. |
int |
maxSize()
Gets the maximum size of the collection (the bound). |
boolean |
offer(E element)
Adds the given element to this queue. |
E |
peek()
|
E |
poll()
|
E |
remove()
|
int |
size()
Returns the number of elements stored in the queue. |
Methods inherited from class java.util.AbstractCollection |
---|
addAll, contains, containsAll, remove, removeAll, retainAll, toArray, toArray, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Collection |
---|
addAll, contains, containsAll, equals, hashCode, remove, removeAll, retainAll, toArray, toArray |
Methods inherited from interface java.util.Collection |
---|
addAll, contains, containsAll, equals, hashCode, remove, removeAll, retainAll, toArray, toArray |
Constructor Detail |
---|
public CircularFifoQueue()
public CircularFifoQueue(int size)
size
- the size of the queue (cannot be changed)
IllegalArgumentException
- if the size is < 1public CircularFifoQueue(Collection<E> coll)
coll
- the collection to copy into the queue, may not be null
NullPointerException
- if the collection is nullMethod Detail |
---|
public int size()
size
in interface Collection<E>
size
in class AbstractCollection<E>
public boolean isEmpty()
isEmpty
in interface Collection<E>
isEmpty
in class AbstractCollection<E>
public boolean isFull()
A CircularFifoQueue
can never be full, thus this returns always
false
.
isFull
in interface BoundedCollection<E>
false
public int maxSize()
maxSize
in interface BoundedCollection<E>
public void clear()
clear
in interface Collection<E>
clear
in class AbstractCollection<E>
public boolean add(E element)
add
in interface Collection<E>
add
in class AbstractCollection<E>
element
- the element to add
NullPointerException
- if the given element is nullpublic E get(int index)
index
- the position of the element in the queue
index
NoSuchElementException
- if the requested position is outside the range [0, size)public boolean offer(E element)
offer
in interface Queue<E>
element
- the element to add
NullPointerException
- if the given element is nullpublic E poll()
poll
in interface Queue<E>
public E element()
element
in interface Queue<E>
public E peek()
peek
in interface Queue<E>
public E remove()
remove
in interface Queue<E>
public Iterator<E> iterator()
iterator
in interface Iterable<E>
iterator
in interface Collection<E>
iterator
in class AbstractCollection<E>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |