E
- the type of elements held in this collection@NotThreadSafe
final class LinkedDeque<E extends Linked<E>>
extends AbstractCollection<E>
implements Deque<E>
Deque
interface where the link
pointers are tightly integrated with the element. Linked deques have no
capacity restrictions; they grow as necessary to support usage. They are not
thread-safe; in the absence of external synchronization, they do not support
concurrent access by multiple threads. Null elements are prohibited.
Most LinkedDeque operations run in constant time by assuming that
the Linked
parameter is associated with the deque instance. Any usage
that violates this assumption will result in non-deterministic behavior.
The iterators returned by this class are not fail-fast: If the deque is modified at any time after the iterator is created, the iterator will be in an unknown state. Thus, in the face of concurrent modification, the iterator risks arbitrary, non-deterministic behavior at an undetermined time in the future.
Modifier and Type | Class and Description |
---|---|
(package private) class |
LinkedDeque.AbstractLinkedIterator |
Modifier and Type | Field and Description |
---|---|
(package private) E |
first
Pointer to first node.
|
(package private) E |
last
Pointer to last node.
|
Constructor and Description |
---|
LinkedDeque() |
Modifier and Type | Method and Description |
---|---|
boolean |
add(E e) |
void |
addFirst(E e) |
void |
addLast(E e) |
(package private) void |
checkNotEmpty() |
void |
clear() |
(package private) boolean |
contains(Linked<?> e) |
boolean |
contains(Object o) |
Iterator<E> |
descendingIterator() |
E |
element() |
E |
getFirst() |
E |
getLast() |
boolean |
isEmpty() |
Iterator<E> |
iterator() |
(package private) void |
linkFirst(E e)
Links the element to the front of the deque so that it becomes the first
element.
|
(package private) void |
linkLast(E e)
Links the element to the back of the deque so that it becomes the last
element.
|
void |
moveToBack(E e)
Moves the element to the back of the deque so that it becomes the last
element.
|
void |
moveToFront(E e)
Moves the element to the front of the deque so that it becomes the first
element.
|
boolean |
offer(E e) |
boolean |
offerFirst(E e) |
boolean |
offerLast(E e) |
E |
peek() |
E |
peekFirst() |
E |
peekLast() |
E |
poll() |
E |
pollFirst() |
E |
pollLast() |
E |
pop() |
void |
push(E e) |
E |
remove() |
(package private) boolean |
remove(E e) |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
E |
removeFirst() |
boolean |
removeFirstOccurrence(Object o) |
E |
removeLast() |
boolean |
removeLastOccurrence(Object o) |
int |
size() |
(package private) void |
unlink(E e)
Unlinks the non-null element.
|
(package private) E |
unlinkFirst()
Unlinks the non-null first element.
|
(package private) E |
unlinkLast()
Unlinks the non-null last element.
|
addAll, containsAll, retainAll, toArray, toArray, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
E extends Linked<E> first
void linkFirst(E e)
e
- the unlinked elementvoid linkLast(E e)
e
- the unlinked elementE unlinkFirst()
E unlinkLast()
void unlink(E e)
public boolean isEmpty()
void checkNotEmpty()
public int size()
Beware that, unlike in most collections, this method is NOT a constant-time operation.
public void clear()
public boolean contains(Object o)
boolean contains(Linked<?> e)
public void moveToFront(E e)
e
- the linked elementpublic void moveToBack(E e)
e
- the linked elementpublic E peek()
public E element()
public boolean offer(E e)
public boolean offerFirst(E e)
public boolean offerLast(E e)
public boolean add(E e)
public E poll()
public E remove()
public boolean remove(Object o)
boolean remove(E e)
public E removeFirst()
public boolean removeFirstOccurrence(Object o)
public boolean removeLastOccurrence(Object o)
public boolean removeAll(Collection<?> c)
public Iterator<E> iterator()
Copyright © 2010-2020 Toolsverse. All Rights Reserved.