Class LinkedDeque<E extends Linked<E>>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- com.googlecode.concurrentlinkedhashmap.LinkedDeque<E>
-
- Type Parameters:
E
- the type of elements held in this collection
- All Implemented Interfaces:
java.lang.Iterable<E>
,java.util.Collection<E>
,java.util.Deque<E>
,java.util.Queue<E>
@NotThreadSafe final class LinkedDeque<E extends Linked<E>> extends java.util.AbstractCollection<E> implements java.util.Deque<E>
Linked list implementation of theDeque
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
LinkedDeque.AbstractLinkedIterator
-
Constructor Summary
Constructors Constructor Description LinkedDeque()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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(java.lang.Object o)
java.util.Iterator<E>
descendingIterator()
E
element()
E
getFirst()
E
getLast()
boolean
isEmpty()
java.util.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(java.lang.Object o)
boolean
removeAll(java.util.Collection<?> c)
E
removeFirst()
boolean
removeFirstOccurrence(java.lang.Object o)
E
removeLast()
boolean
removeLastOccurrence(java.lang.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.-
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
-
-
-
Method Detail
-
linkFirst
void linkFirst(E e)
Links the element to the front of the deque so that it becomes the first element.- Parameters:
e
- the unlinked element
-
linkLast
void linkLast(E e)
Links the element to the back of the deque so that it becomes the last element.- Parameters:
e
- the unlinked element
-
unlinkFirst
E unlinkFirst()
Unlinks the non-null first element.
-
unlinkLast
E unlinkLast()
Unlinks the non-null last element.
-
unlink
void unlink(E e)
Unlinks the non-null element.
-
isEmpty
public boolean isEmpty()
-
checkNotEmpty
void checkNotEmpty()
-
size
public int size()
Beware that, unlike in most collections, this method is NOT a constant-time operation.
-
clear
public void clear()
-
contains
public boolean contains(java.lang.Object o)
-
contains
boolean contains(Linked<?> e)
-
moveToFront
public void moveToFront(E e)
Moves the element to the front of the deque so that it becomes the first element.- Parameters:
e
- the linked element
-
moveToBack
public void moveToBack(E e)
Moves the element to the back of the deque so that it becomes the last element.- Parameters:
e
- the linked element
-
peek
public E peek()
-
peekFirst
public E peekFirst()
-
peekLast
public E peekLast()
-
getFirst
public E getFirst()
-
element
public E element()
-
offer
public boolean offer(E e)
-
offerFirst
public boolean offerFirst(E e)
-
offerLast
public boolean offerLast(E e)
-
add
public boolean add(E e)
-
addFirst
public void addFirst(E e)
-
addLast
public void addLast(E e)
-
poll
public E poll()
-
pollFirst
public E pollFirst()
-
pollLast
public E pollLast()
-
remove
public E remove()
-
remove
public boolean remove(java.lang.Object o)
-
remove
boolean remove(E e)
-
removeFirst
public E removeFirst()
-
removeFirstOccurrence
public boolean removeFirstOccurrence(java.lang.Object o)
-
removeLast
public E removeLast()
-
removeLastOccurrence
public boolean removeLastOccurrence(java.lang.Object o)
-
removeAll
public boolean removeAll(java.util.Collection<?> c)
-
iterator
public java.util.Iterator<E> iterator()
- Specified by:
iterator
in interfacejava.util.Collection<E extends Linked<E>>
- Specified by:
iterator
in interfacejava.util.Deque<E extends Linked<E>>
- Specified by:
iterator
in interfacejava.lang.Iterable<E extends Linked<E>>
- Specified by:
iterator
in classjava.util.AbstractCollection<E extends Linked<E>>
-
-