E - type of contained elementspublic class FastLimitedQueue<E> extends Object
| Constructor and Description |
|---|
FastLimitedQueue(int sizeLimit)
Creat a new instance with given size limit.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E e)
Add an element at the tail of the queue, replacing the least recently added item if the queue is full.
|
boolean |
addAll(Collection<E> items)
Add the given collection of items.
|
void |
clear()
Clear the queue.
|
boolean |
contains(E e)
Checks whether the given item is contained in the queue.
|
E |
remove()
Retrieves and removes the head of the queue, or returns
null if the queue is empty. |
int |
size()
Get the number of items contained in the queue.
|
int |
sizeLimit()
Get the size limit of the queue.
|
public FastLimitedQueue(int sizeLimit)
sizeLimit - size limit of the queue, required to be strictly positiveIllegalArgumentException - if size is not strictly positivepublic boolean add(E e)
e - element to add at the tail of the queue, if not already contained in the queuetrue if the given item was not yet contained in the queuepublic boolean addAll(Collection<E> items)
items - items to add to the queuetrue if the queue is modified, i.e. if at least one new item has been addedpublic E remove()
null if the queue is empty.
The head of the queue corresponds to the least recently added item (if any).null if queue is emptypublic boolean contains(E e)
e - given itemtrue if e is contained in the queuepublic int size()
public int sizeLimit()
public void clear()
Copyright © 2016. All rights reserved.