Top Description Fields Constructors Methods
org.assertj.core.presentation

pack-priv final Class BoundedQueue<T>

extends AbstractQueue<T>
Class Inheritance
Static Imports
org.assertj.core.util.Preconditions.checkArgument

A queue with a fixed maximum size. Once the queue is full, no more elements can be added until an element is removed.

Field Summary

Modifier and TypeField and Description
private final int
capacity

The maximum number of elements that can be present.

private final Queue<T>
data

Queue that never holds more than capacity elements.

Constructor Summary

AccessConstructor and Description
pack-priv
BoundedQueue(int
the maximum number of elements the queue can hold
capacity
)

Creates a new BoundedQueue.

Method Summary

Modifier and TypeMethod and Description
public Iterator<T>
iterator()

Implements abstract java.util.AbstractCollection.iterator.

Implements java.util.Collection.iterator.

Returns an iterator over the elements in this collection.
public boolean
offer(T
the element to add
element
)

Implements java.util.Queue.offer.

Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions.
public T
peek()

Implements java.util.Queue.peek.

Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty.
public T
poll()

Implements java.util.Queue.poll.

Retrieves and removes the head of this queue, or returns null if this queue is empty.
public int
size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.Collection.size.

Returns the number of elements in this collection.
Inherited from java.util.AbstractQueue:
addaddAllclearelementremove

Field Detail

capacityback to summary
private final int capacity

The maximum number of elements that can be present.

databack to summary
private final Queue<T> data

Queue that never holds more than capacity elements.

Constructor Detail

BoundedQueueback to summary
pack-priv BoundedQueue(int capacity)

Creates a new BoundedQueue.

Parameters
capacity:int

the maximum number of elements the queue can hold

Exceptions
IllegalArgumentException:
if the capacity is negative

Method Detail

iteratorback to summary
public Iterator<T> iterator()

Implements abstract java.util.AbstractCollection.iterator.

Implements java.util.Collection.iterator.

Doc from java.util.Collection.iterator.

Returns an iterator over the elements in this collection. There are no guarantees concerning the order in which the elements are returned (unless this collection is an instance of some class that provides a guarantee).

Returns:Iterator<T>

an Iterator over the elements in this collection

Annotations
@Override
offerback to summary
public boolean offer(T element)

Implements java.util.Queue.offer.

Doc from java.util.Queue.offer.

Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions. When using a capacity-restricted queue, this method is generally preferable to add, which can fail to insert an element only by throwing an exception.

Parameters
element:T

the element to add

Returns:boolean

true if the element was added to this queue, else false

Annotations
@Override
peekback to summary
public T peek()

Implements java.util.Queue.peek.

Doc from java.util.Queue.peek.

Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty.

Returns:T

the head of this queue, or null if this queue is empty

Annotations
@Override
pollback to summary
public T poll()

Implements java.util.Queue.poll.

Doc from java.util.Queue.poll.

Retrieves and removes the head of this queue, or returns null if this queue is empty.

Returns:T

the head of this queue, or null if this queue is empty

Annotations
@Override
sizeback to summary
public int size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.Collection.size.

Doc from java.util.Collection.size.

Returns the number of elements in this collection. If this collection contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Returns:int

the number of elements in this collection

Annotations
@Override