Class AbstractLinkedDeque<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- com.github.benmanes.caffeine.cache.AbstractLinkedDeque<E>
-
- Type Parameters:
E
- the type of elements held in this collection
- All Implemented Interfaces:
LinkedDeque<E>
,java.lang.Iterable<E>
,java.util.Collection<E>
,java.util.Deque<E>
,java.util.Queue<E>
- Direct Known Subclasses:
AccessOrderDeque
,WriteOrderDeque
@NotThreadSafe abstract class AbstractLinkedDeque<E> extends java.util.AbstractCollection<E> implements LinkedDeque<E>
This class provides a skeletal implementation of theLinkedDeque
interface to minimize the effort required to implement this interface.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
AbstractLinkedDeque.AbstractLinkedIterator
-
Nested classes/interfaces inherited from interface com.github.benmanes.caffeine.cache.LinkedDeque
LinkedDeque.PeekingIterator<E>
-
-
Constructor Summary
Constructors Constructor Description AbstractLinkedDeque()
-
Method Summary
All Methods Instance Methods Abstract 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()
abstract boolean
contains(java.lang.Object o)
LinkedDeque.PeekingIterator<E>
descendingIterator()
E
element()
E
getFirst()
E
getLast()
boolean
isEmpty()
boolean
isFirst(E e)
Returns if the element is at the front of the deque.boolean
isLast(E e)
Returns if the element is at the back of the deque.LinkedDeque.PeekingIterator<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()
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, remove, retainAll, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
containsAll, equals, hashCode, parallelStream, removeIf, retainAll, spliterator, stream, toArray, toArray, toArray
-
Methods inherited from interface com.github.benmanes.caffeine.cache.LinkedDeque
getNext, getPrevious, setNext, setPrevious
-
-
-
-
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 abstract boolean contains(java.lang.Object o)
-
isFirst
public boolean isFirst(E e)
Description copied from interface:LinkedDeque
Returns if the element is at the front of the deque.- Specified by:
isFirst
in interfaceLinkedDeque<E>
- Parameters:
e
- the linked element
-
isLast
public boolean isLast(E e)
Description copied from interface:LinkedDeque
Returns if the element is at the back of the deque.- Specified by:
isLast
in interfaceLinkedDeque<E>
- Parameters:
e
- the linked element
-
moveToFront
public void moveToFront(E e)
Description copied from interface:LinkedDeque
Moves the element to the front of the deque so that it becomes the first element.- Specified by:
moveToFront
in interfaceLinkedDeque<E>
- Parameters:
e
- the linked element
-
moveToBack
public void moveToBack(E e)
Description copied from interface:LinkedDeque
Moves the element to the back of the deque so that it becomes the last element.- Specified by:
moveToBack
in interfaceLinkedDeque<E>
- Parameters:
e
- the linked element
-
peek
public E peek()
-
element
public E element()
-
offer
public boolean offer(E e)
-
add
public boolean add(E e)
-
poll
public E poll()
-
remove
public E remove()
-
removeFirstOccurrence
public boolean removeFirstOccurrence(java.lang.Object o)
- Specified by:
removeFirstOccurrence
in interfacejava.util.Deque<E>
-
removeLastOccurrence
public boolean removeLastOccurrence(java.lang.Object o)
- Specified by:
removeLastOccurrence
in interfacejava.util.Deque<E>
-
removeAll
public boolean removeAll(java.util.Collection<?> c)
-
iterator
public LinkedDeque.PeekingIterator<E> iterator()
-
descendingIterator
public LinkedDeque.PeekingIterator<E> descendingIterator()
- Specified by:
descendingIterator
in interfacejava.util.Deque<E>
- Specified by:
descendingIterator
in interfaceLinkedDeque<E>
-
-