E - public class DequeSnapshot<E> extends Object implements AutoCloseable, Collection<E>
SnapshotableDeque implements Collection.
Write operations of collection (...) impacts the source deque, not the snapshot itself.
A snapshot is not a deep copy of deque's content at the time of creation. The overhead to create a snapshot is very slightly, regardless of deque's size.
Iterate through a snapshot also does not produce a deep copy and requires no locks inside of snapshot or source deque.
A Snapshot has to be closed if it is not required anymore. Otherwise the helper links of removed elements remain in source deque and the gc does not release the memory.| Modifier and Type | Class and Description |
|---|---|
protected class |
DequeSnapshot.ElementSnapshotIterator
private helper class
|
protected class |
DequeSnapshot.LinkSnapshotIterator
private helper class
|
protected class |
DequeSnapshot.NodeSnapshotIterator
private helper class
|
protected class |
DequeSnapshot.SnapshotIterator
private helper class
|
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
closed |
protected DequeNode.Link<E> |
firstLink |
protected DequeNode.Link<E> |
lastLink |
protected Integer |
pollCapacity |
protected long |
size |
protected SnapshotableDeque<E> |
snapshotableDeque |
protected UUID |
uuid |
protected SnapshotableDeque.SnapshotVersion<E> |
version |
| Modifier | Constructor and Description |
|---|---|
protected |
DequeSnapshot(SnapshotableDeque<E> snapshotableDeque,
boolean poll,
Integer pollCapacity) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E e) |
boolean |
addAll(Collection<? extends E> c) |
void |
clear() |
void |
close() |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> c) |
boolean |
equals(Object obj) |
E |
getFirstElement()
Returns first element
|
protected DequeNode.Link<E> |
getFirstLink() |
DequeNode<E> |
getFirstNode()
Returns first node
|
E |
getLastElement()
Returns last element
|
protected DequeNode.Link<E> |
getLastLink() |
DequeNode<E> |
getLastNode()
Returns last node
|
protected DequeNode.Link<E> |
getLink(E o)
Find link by element (same object)
|
DequeNode<E> |
getNode(E o)
Find node by element (same object)
|
protected SnapshotableDeque<E> |
getParent() |
long |
getVersion()
Returns the version of deque the snapshot was created
|
int |
hashCode() |
boolean |
isClosed()
returns true if snapshot is closed, otherwise false
|
boolean |
isEmpty() |
Iterator<E> |
iterator() |
protected Iterable<DequeNode.Link<E>> |
linkIterable()
Returns link iterable
|
Iterable<DequeNode<E>> |
nodeIterable()
Returns node iterable
|
Stream<DequeNode<E>> |
nodeStream()
Returns node stream
|
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
boolean |
retainAll(Collection<?> c) |
int |
size() |
Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitparallelStream, removeIf, spliterator, streamprotected UUID uuid
protected SnapshotableDeque.SnapshotVersion<E> version
protected SnapshotableDeque<E> snapshotableDeque
protected DequeNode.Link<E> firstLink
protected DequeNode.Link<E> lastLink
protected volatile boolean closed
protected long size
protected Integer pollCapacity
protected DequeSnapshot(SnapshotableDeque<E> snapshotableDeque, boolean poll, Integer pollCapacity)
protected SnapshotableDeque<E> getParent()
public void close()
close in interface AutoCloseablepublic boolean isClosed()
public long getVersion()
protected DequeNode.Link<E> getLink(E o)
o - elementpublic DequeNode<E> getNode(E o)
o - elementprotected Iterable<DequeNode.Link<E>> linkIterable()
public Iterable<DequeNode<E>> nodeIterable()
public int size()
size in interface Collection<E>public boolean isEmpty()
isEmpty in interface Collection<E>public boolean contains(Object o)
contains 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)
add in interface Collection<E>public boolean remove(Object o)
remove in interface Collection<E>public boolean containsAll(Collection<?> c)
containsAll in interface Collection<E>public boolean addAll(Collection<? extends E> c)
addAll 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 void clear()
clear in interface Collection<E>public E getFirstElement()
protected DequeNode.Link<E> getFirstLink()
public E getLastElement()
protected DequeNode.Link<E> getLastLink()
public int hashCode()
hashCode in interface Collection<E>hashCode in class ObjectCopyright © 2020. All rights reserved.