Inserts the specified element into the queue represented by this deque
(in other words, at the tail of this deque) if it is possible to do so
immediately without violating capacity restrictions, returning
true
upon success and throwing an
IllegalStateException
if no space is currently available.
When using a capacity-restricted deque, it is generally preferable to
use offer
.
This method is equivalent to addLast
.
e | the element to add |
true
(as specified by Collection.add
)
Returns true
if this deque contains the specified element.
More formally, returns true
if and only if this deque contains
at least one element e
such that
(o==null ? e==null : o.equals(e)).
o | element whose presence in this deque is to be tested |
true
if this deque contains the specified element
Retrieves, but does not remove, the head of the queue represented by
this deque (in other words, the first element of this deque).
This method differs from peek
only in that it throws an
exception if this deque is empty.
This method is equivalent to getFirst()
.
Returns an iterator over the elements in this deque in proper sequence. The elements will be returned in order from first (head) to last (tail).
Inserts the specified element into the queue represented by this deque
(in other words, at the tail of this deque) if it is possible to do so
immediately without violating capacity restrictions, returning
true
upon success and false
if no space is currently
available. When using a capacity-restricted deque, this method is
generally preferable to the add
method, which can fail to
insert an element only by throwing an exception.
This method is equivalent to offerLast
.
e | the element to add |
true
if the element was added to this deque, else
false
Retrieves, but does not remove, the head of the queue represented by
this deque (in other words, the first element of this deque), or
returns null
if this deque is empty.
This method is equivalent to peekFirst()
.
null
if this deque is empty
Retrieves and removes the head of the queue represented by this deque
(in other words, the first element of this deque), or returns
null
if this deque is empty.
This method is equivalent to pollFirst()
.
null
if
this deque is empty
Retrieves and removes the head of the queue represented by this deque
(in other words, the first element of this deque).
This method differs from poll
only in that it throws an
exception if this deque is empty.
This method is equivalent to removeFirst()
.
Removes the first occurrence of the specified element from this deque.
If the deque does not contain the element, it is unchanged.
More formally, removes the first element e
such that
(o==null ? e==null : o.equals(e))
(if such an element exists).
Returns true
if this deque contained the specified element
(or equivalently, if this deque changed as a result of the call).
This method is equivalent to removeFirstOccurrence(Object)
.
o | element to be removed from this deque, if present |
true
if an element was removed as a result of this call
Returns the number of elements in this deque.
Diagram: Collection Queue