E - the type of elements in dequepublic class SnapshotableDeque<E> extends Object implements AutoCloseable, Deque<E>
Deque. Iterating through deque requires creating a DequeSnapshot.| Modifier and Type | Class and Description |
|---|---|
protected class |
SnapshotableDeque.Bollard
Internal helper class to reference begin or end of branch.
|
protected static class |
SnapshotableDeque.ClearCompleteForwardBranch<E>
Internal helper class
|
protected static class |
SnapshotableDeque.Eyebolt<E>
Internal helper class to reference begin or end of branch.
|
static class |
SnapshotableDeque.LinkMode |
protected static class |
SnapshotableDeque.SnapshotVersion<E>
Internal helper class to manage versions
|
| Modifier and Type | Field and Description |
|---|---|
protected SnapshotableDeque.Bollard |
begin |
protected long |
capacity |
protected SnapshotableDeque.Bollard |
end |
protected LinkedList<INodeEventHandler<E>> |
eventHandlerList |
protected SnapshotableDeque.SnapshotVersion<E> |
modificationVersion |
protected long |
nodeSize |
protected LinkedList<DequeNode.Link<E>> |
obsoleteList |
protected Set<SnapshotableDeque.SnapshotVersion<E>> |
openSnapshotVersionList |
protected ReentrantReadWriteLock.ReadLock |
readLock |
protected ReentrantReadWriteLock |
rwLock |
protected SnapshotableDeque.SnapshotVersion<E> |
snapshotVersion |
protected UUID |
uuid |
protected ReentrantReadWriteLock.WriteLock |
writeLock |
| Constructor and Description |
|---|
SnapshotableDeque()
Constructor to create a SnapshotableDeque .
|
SnapshotableDeque(long capacity)
Constructor to create a SnapshotableDeque with specified capacity .
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E e) |
boolean |
addAll(Collection<? extends E> c) |
void |
addFirst(E e) |
void |
addLast(E e) |
void |
clear() |
void |
close() |
void |
computeProcedure(Consumer<SnapshotableDeque<E>> procedure)
Compute procedure undisturbed by concurrency updates.
|
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> c) |
DequeSnapshot<E> |
createSnapshot()
create a snapshot
|
DequeSnapshot<E> |
createSnapshotPoll()
create a snapshot poll
|
Iterator<E> |
descendingIterator() |
void |
dispose()
Helps gc to clean memory.
|
E |
element() |
boolean |
equals(Object obj) |
long |
getCapacity() |
E |
getFirst() |
E |
getLast() |
protected SnapshotableDeque.SnapshotVersion<E> |
getModificationVersion()
Internal helper method returns current modification version.
|
int |
hashCode() |
boolean |
isEmpty() |
Iterator<E> |
iterator() |
DequeNode<E> |
link(SnapshotableDeque.LinkMode linkMode,
E element)
link (append or prepend) new element to deque.
|
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) |
void |
registerEventHandler(INodeEventHandler<E> eventHandler)
register node event handler
|
long |
remainingCapacity()
returns the remaining capacity
|
E |
remove() |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
E |
removeFirst() |
boolean |
removeFirstOccurrence(Object o) |
E |
removeLast() |
boolean |
removeLastOccurrence(Object o) |
protected void |
removeSnapshotVersion(SnapshotableDeque.SnapshotVersion<E> snapshotVersion)
Internal method to remove snapshot and clean-ups
|
boolean |
retainAll(Collection<?> c) |
void |
setCapacity(long capacity) |
protected void |
setObsolete(DequeNode.Link<E> link)
Internal method to set link to obsolete
|
int |
size() |
Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
void |
unregisterEventHandler(INodeEventHandler<E> eventHandler)
unregister node event handler
|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitparallelStream, removeIf, spliterator, streamprotected ReentrantReadWriteLock rwLock
protected ReentrantReadWriteLock.ReadLock readLock
protected ReentrantReadWriteLock.WriteLock writeLock
protected SnapshotableDeque.Bollard begin
protected SnapshotableDeque.Bollard end
protected LinkedList<DequeNode.Link<E>> obsoleteList
protected SnapshotableDeque.SnapshotVersion<E> modificationVersion
protected SnapshotableDeque.SnapshotVersion<E> snapshotVersion
protected Set<SnapshotableDeque.SnapshotVersion<E>> openSnapshotVersionList
protected volatile LinkedList<INodeEventHandler<E>> eventHandlerList
protected volatile long nodeSize
protected volatile long capacity
protected UUID uuid
public SnapshotableDeque()
public SnapshotableDeque(long capacity)
public long getCapacity()
public void setCapacity(long capacity)
protected SnapshotableDeque.SnapshotVersion<E> getModificationVersion()
public long remainingCapacity()
public void registerEventHandler(INodeEventHandler<E> eventHandler)
eventHandler - event handler to registerpublic void unregisterEventHandler(INodeEventHandler<E> eventHandler)
eventHandler - eventHandler event handler to unregisterprotected void removeSnapshotVersion(SnapshotableDeque.SnapshotVersion<E> snapshotVersion)
snapshotVersion - version of dequeprotected void setObsolete(DequeNode.Link<E> link)
link - link to set obsoletepublic void computeProcedure(Consumer<SnapshotableDeque<E>> procedure)
Don't create new Threads inside procedure. There is a risk of a deadlock
procedure - public int hashCode()
hashCode in interface Collection<E>hashCode in class Objectpublic boolean equals(Object obj)
equals in interface Collection<E>equals in class Objectpublic void dispose()
public DequeNode<E> link(SnapshotableDeque.LinkMode linkMode, E element)
linkMode - append or prependelement - item to linkpublic DequeSnapshot<E> createSnapshot()
public DequeSnapshot<E> createSnapshotPoll()
public boolean addAll(Collection<? extends E> c)
addAll in interface Collection<E>public void clear()
clear in interface Collection<E>public boolean remove(Object o)
public boolean containsAll(Collection<?> c)
containsAll in interface Collection<E>public boolean contains(Object o)
public int size()
public boolean isEmpty()
isEmpty in interface Collection<E>public boolean removeAll(Collection<?> c)
removeAll in interface Collection<E>public boolean retainAll(Collection<?> c)
retainAll in interface Collection<E>public Object[] toArray()
toArray in interface Collection<E>public <T> T[] toArray(T[] a)
toArray in interface Collection<E>public boolean add(E e)
public E element()
public boolean offer(E e)
public E peek()
public E poll()
public E remove()
public boolean offerFirst(E e)
offerFirst in interface Deque<E>public Iterator<E> descendingIterator()
descendingIterator in interface Deque<E>public E removeFirst()
removeFirst in interface Deque<E>public E removeLast()
removeLast in interface Deque<E>public boolean removeFirstOccurrence(Object o)
removeFirstOccurrence in interface Deque<E>public boolean removeLastOccurrence(Object o)
removeLastOccurrence in interface Deque<E>public void close()
close in interface AutoCloseableCopyright © 2020. All rights reserved.