Top Description Inners Fields Constructors Methods
com.fasterxml.jackson.databind.util.internal

pack-priv final Class LinkedDeque<E extends Linked<E>>

Additional top-level class in compilation unit: Linked.

extends AbstractCollection<E extends Linked<E>>
implements Deque<E extends Linked<E>>
Class Inheritance
All Implemented Interfaces
java.util.Deque, java.util.SequencedCollection, java.util.Collection, java.lang.Iterable, java.util.Queue
Type Parameters
<E>
the type of elements held in this collection
Imports
java.util.AbstractCollection, .Collection, .Deque, .Iterator, .NoSuchElementException

Linked list implementation of the 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.

Author
[email protected] (Ben Manes)
See Also
http://code.google.com/p/concurrentlinkedhashmap/

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv abstract class

Field Summary

Modifier and TypeField and Description
pack-priv E
first

Pointer to first node.

pack-priv E
last

Pointer to last node.

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
add(E
the element to add
e
)

Overrides java.util.AbstractCollection.add.

Implements java.util.Deque.add, java.util.Collection.add.

Inserts the specified element into the queue represented by this deque (in other words, at the tail of this deque) if it is possible to do so immediately without violating capacity restrictions, returning true upon success and throwing an IllegalStateException if no space is currently available.

public void
addFirst(E
the element to add
e
)

Implements java.util.Deque.addFirst.

Inserts the specified element at the front of this deque if it is possible to do so immediately without violating capacity restrictions, throwing an IllegalStateException if no space is currently available.

public void
addLast(E
the element to add
e
)

Implements java.util.Deque.addLast.

Inserts the specified element at the end of this deque if it is possible to do so immediately without violating capacity restrictions, throwing an IllegalStateException if no space is currently available.

pack-priv void
public void
clear()

Overrides java.util.AbstractCollection.clear.

Implements java.util.Collection.clear.

Removes all of the elements from this collection (optional operation).

public boolean
contains(Object
element whose presence in this deque is to be tested
o
)

Overrides java.util.AbstractCollection.contains.

Implements java.util.Deque.contains, java.util.Collection.contains.

Returns true if this deque contains the specified element.

pack-priv boolean
public Iterator<E>
descendingIterator()

Implements java.util.Deque.descendingIterator.

Returns an iterator over the elements in this deque in reverse sequential order.

public E
element()

Implements java.util.Deque.element.

Retrieves, but does not remove, the head of the queue represented by this deque (in other words, the first element of this deque).

public E
getFirst()

Implements java.util.Deque.getFirst.

Retrieves, but does not remove, the first element of this deque.

public E
getLast()

Implements java.util.Deque.getLast.

Retrieves, but does not remove, the last element of this deque.

public boolean
isEmpty()

Overrides java.util.AbstractCollection.isEmpty.

Implements java.util.Collection.isEmpty.

Returns true if this collection contains no elements.

public Iterator<E>
iterator()

Implements abstract java.util.AbstractCollection.iterator.

Implements java.util.Deque.iterator, java.util.Collection.iterator.

Returns an iterator over the elements in this deque in proper sequence.

pack-priv void
linkFirst(final E
the unlinked element
e
)

Links the element to the front of the deque so that it becomes the first element.

pack-priv void
linkLast(final E
the unlinked element
e
)

Links the element to the back of the deque so that it becomes the last element.

public void
moveToBack(E
the linked element
e
)

Moves the element to the back of the deque so that it becomes the last element.

public void
moveToFront(E
the linked element
e
)

Moves the element to the front of the deque so that it becomes the first element.

public boolean
offer(E
the element to add
e
)

Implements java.util.Deque.offer.

Inserts the specified element into the queue represented by this deque (in other words, at the tail of this deque) if it is possible to do so immediately without violating capacity restrictions, returning true upon success and false if no space is currently available.

public boolean
offerFirst(E
the element to add
e
)

Implements java.util.Deque.offerFirst.

Inserts the specified element at the front of this deque unless it would violate capacity restrictions.

public boolean
offerLast(E
the element to add
e
)

Implements java.util.Deque.offerLast.

Inserts the specified element at the end of this deque unless it would violate capacity restrictions.

public E
peek()

Implements java.util.Deque.peek.

Retrieves, but does not remove, the head of the queue represented by this deque (in other words, the first element of this deque), or returns null if this deque is empty.

public E
peekFirst()

Implements java.util.Deque.peekFirst.

Retrieves, but does not remove, the first element of this deque, or returns null if this deque is empty.

public E
peekLast()

Implements java.util.Deque.peekLast.

Retrieves, but does not remove, the last element of this deque, or returns null if this deque is empty.

public E
poll()

Implements java.util.Deque.poll.

Retrieves and removes the head of the queue represented by this deque (in other words, the first element of this deque), or returns null if this deque is empty.

public E
pollFirst()

Implements java.util.Deque.pollFirst.

Retrieves and removes the first element of this deque, or returns null if this deque is empty.

public E
pollLast()

Implements java.util.Deque.pollLast.

Retrieves and removes the last element of this deque, or returns null if this deque is empty.

public E
pop()

Implements java.util.Deque.pop.

Pops an element from the stack represented by this deque.

public void
push(E
the element to push
e
)

Implements java.util.Deque.push.

Pushes an element onto the stack represented by this deque (in other words, at the head of this deque) if it is possible to do so immediately without violating capacity restrictions, throwing an IllegalStateException if no space is currently available.

public E
remove()

Implements java.util.Deque.remove.

Retrieves and removes the head of the queue represented by this deque (in other words, the first element of this deque).

public boolean
remove(Object
element to be removed from this deque, if present
o
)

Overrides java.util.AbstractCollection.remove.

Implements java.util.Deque.remove, java.util.Collection.remove.

Removes the first occurrence of the specified element from this deque.

pack-priv boolean
remove(E e)

public boolean
removeAll(Collection<?>
collection containing elements to be removed from this collection
c
)

Overrides java.util.AbstractCollection.removeAll.

Implements java.util.Collection.removeAll.

Removes all of this collection's elements that are also contained in the specified collection (optional operation).

public E
removeFirst()

Implements java.util.Deque.removeFirst.

Retrieves and removes the first element of this deque.

public boolean
removeFirstOccurrence(Object
element to be removed from this deque, if present
o
)

Implements java.util.Deque.removeFirstOccurrence.

Removes the first occurrence of the specified element from this deque.

public E
removeLast()

Implements java.util.Deque.removeLast.

Retrieves and removes the last element of this deque.

public boolean
removeLastOccurrence(Object
element to be removed from this deque, if present
o
)

Implements java.util.Deque.removeLastOccurrence.

Removes the last occurrence of the specified element from this deque.

public int
size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.Deque.size, java.util.Collection.size.

Returns the number of elements in this deque.

pack-priv E
unlinkFirst()

Unlinks the non-null first element.

pack-priv E
unlinkLast()

Unlinks the non-null last element.

Inherited from java.util.AbstractCollection:
addAllcontainsAllretainAlltoArraytoArraytoString

Field Detail

firstback to summary
pack-priv E first

Pointer to first node. Invariant: (first == null && last == null) || (first.prev == null)

lastback to summary
pack-priv E last

Pointer to last node. Invariant: (first == null && last == null) || (last.next == null)

Constructor Detail

LinkedDequeback to summary
pack-priv LinkedDeque()

Method Detail

addback to summary
public boolean add(E e)

Overrides java.util.AbstractCollection.add.

Implements java.util.Deque.add, java.util.Collection.add.

Doc from java.util.Deque.add.

Inserts the specified element into the queue represented by this deque (in other words, at the tail of this deque) if it is possible to do so immediately without violating capacity restrictions, returning true upon success and throwing an IllegalStateException if no space is currently available. When using a capacity-restricted deque, it is generally preferable to use offer.

This method is equivalent to addLast.

Parameters
e:E

the element to add

Returns:boolean

true (as specified by Collection#add)

Annotations
@Override
addFirstback to summary
public void addFirst(E e)

Implements java.util.Deque.addFirst.

Doc from java.util.Deque.addFirst.

Inserts the specified element at the front of this deque if it is possible to do so immediately without violating capacity restrictions, throwing an IllegalStateException if no space is currently available. When using a capacity-restricted deque, it is generally preferable to use method offerFirst.

Parameters
e:E

the element to add

Annotations
@Override
addLastback to summary
public void addLast(E e)

Implements java.util.Deque.addLast.

Doc from java.util.Deque.addLast.

Inserts the specified element at the end of this deque if it is possible to do so immediately without violating capacity restrictions, throwing an IllegalStateException if no space is currently available. When using a capacity-restricted deque, it is generally preferable to use method offerLast.

This method is equivalent to add.

Parameters
e:E

the element to add

Annotations
@Override
checkNotEmptyback to summary
pack-priv void checkNotEmpty()
clearback to summary
public void clear()

Overrides java.util.AbstractCollection.clear.

Implements java.util.Collection.clear.

Doc from java.util.Collection.clear.

Removes all of the elements from this collection (optional operation). The collection will be empty after this method returns.

Annotations
@Override
containsback to summary
public boolean contains(Object o)

Overrides java.util.AbstractCollection.contains.

Implements java.util.Deque.contains, java.util.Collection.contains.

Doc from java.util.Deque.contains.

Returns true if this deque contains the specified element. More formally, returns true if and only if this deque contains at least one element e such that Objects.equals(o, e).

Parameters
o:Object

element whose presence in this deque is to be tested

Returns:boolean

true if this deque contains the specified element

Annotations
@Override
containsback to summary
pack-priv boolean contains(Linked<?> e)
descendingIteratorback to summary
public Iterator<E> descendingIterator()

Implements java.util.Deque.descendingIterator.

Doc from java.util.Deque.descendingIterator.

Returns an iterator over the elements in this deque in reverse sequential order. The elements will be returned in order from last (tail) to first (head).

Returns:Iterator<E>

an iterator over the elements in this deque in reverse sequence

Annotations
@Override
elementback to summary
public E element()

Implements java.util.Deque.element.

Doc from java.util.Deque.element.

Retrieves, but does not remove, the head of the queue represented by this deque (in other words, the first element of this deque). This method differs from peek only in that it throws an exception if this deque is empty.

This method is equivalent to getFirst().

Returns:E

the head of the queue represented by this deque

Annotations
@Override
getFirstback to summary
public E getFirst()

Implements java.util.Deque.getFirst.

Doc from java.util.Deque.getFirst.

Retrieves, but does not remove, the first element of this deque. This method differs from peekFirst only in that it throws an exception if this deque is empty.

Returns:E

the head of this deque

Annotations
@Override
getLastback to summary
public E getLast()

Implements java.util.Deque.getLast.

Doc from java.util.Deque.getLast.

Retrieves, but does not remove, the last element of this deque. This method differs from peekLast only in that it throws an exception if this deque is empty.

Returns:E

the tail of this deque

Annotations
@Override
isEmptyback to summary
public boolean isEmpty()

Overrides java.util.AbstractCollection.isEmpty.

Implements java.util.Collection.isEmpty.

Doc from java.util.Collection.isEmpty.

Returns true if this collection contains no elements.

Returns:boolean

true if this collection contains no elements

Annotations
@Override
iteratorback to summary
public Iterator<E> iterator()

Implements abstract java.util.AbstractCollection.iterator.

Implements java.util.Deque.iterator, java.util.Collection.iterator.

Doc from java.util.Deque.iterator.

Returns an iterator over the elements in this deque in proper sequence. The elements will be returned in order from first (head) to last (tail).

Returns:Iterator<E>

an iterator over the elements in this deque in proper sequence

Annotations
@Override
linkFirstback to summary
pack-priv void linkFirst(final E e)

Links the element to the front of the deque so that it becomes the first element.

Parameters
e:E

the unlinked element

linkLastback to summary
pack-priv void linkLast(final E e)

Links the element to the back of the deque so that it becomes the last element.

Parameters
e:E

the unlinked element

moveToBackback to summary
public void moveToBack(E e)

Moves the element to the back of the deque so that it becomes the last element.

Parameters
e:E

the linked element

moveToFrontback to summary
public void moveToFront(E e)

Moves the element to the front of the deque so that it becomes the first element.

Parameters
e:E

the linked element

offerback to summary
public boolean offer(E e)

Implements java.util.Deque.offer.

Doc from java.util.Deque.offer.

Inserts the specified element into the queue represented by this deque (in other words, at the tail of this deque) if it is possible to do so immediately without violating capacity restrictions, returning true upon success and false if no space is currently available. When using a capacity-restricted deque, this method is generally preferable to the add method, which can fail to insert an element only by throwing an exception.

This method is equivalent to offerLast.

Parameters
e:E

the element to add

Returns:boolean

true if the element was added to this deque, else false

Annotations
@Override
offerFirstback to summary
public boolean offerFirst(E e)

Implements java.util.Deque.offerFirst.

Doc from java.util.Deque.offerFirst.

Inserts the specified element at the front of this deque unless it would violate capacity restrictions. When using a capacity-restricted deque, this method is generally preferable to the addFirst method, which can fail to insert an element only by throwing an exception.

Parameters
e:E

the element to add

Returns:boolean

true if the element was added to this deque, else false

Annotations
@Override
offerLastback to summary
public boolean offerLast(E e)

Implements java.util.Deque.offerLast.

Doc from java.util.Deque.offerLast.

Inserts the specified element at the end of this deque unless it would violate capacity restrictions. When using a capacity-restricted deque, this method is generally preferable to the addLast method, which can fail to insert an element only by throwing an exception.

Parameters
e:E

the element to add

Returns:boolean

true if the element was added to this deque, else false

Annotations
@Override
peekback to summary
public E peek()

Implements java.util.Deque.peek.

Doc from java.util.Deque.peek.

Retrieves, but does not remove, the head of the queue represented by this deque (in other words, the first element of this deque), or returns null if this deque is empty.

This method is equivalent to peekFirst().

Returns:E

the head of the queue represented by this deque, or null if this deque is empty

Annotations
@Override
peekFirstback to summary
public E peekFirst()

Implements java.util.Deque.peekFirst.

Doc from java.util.Deque.peekFirst.

Retrieves, but does not remove, the first element of this deque, or returns null if this deque is empty.

Returns:E

the head of this deque, or null if this deque is empty

Annotations
@Override
peekLastback to summary
public E peekLast()

Implements java.util.Deque.peekLast.

Doc from java.util.Deque.peekLast.

Retrieves, but does not remove, the last element of this deque, or returns null if this deque is empty.

Returns:E

the tail of this deque, or null if this deque is empty

Annotations
@Override
pollback to summary
public E poll()

Implements java.util.Deque.poll.

Doc from java.util.Deque.poll.

Retrieves and removes the head of the queue represented by this deque (in other words, the first element of this deque), or returns null if this deque is empty.

This method is equivalent to pollFirst().

Returns:E

the first element of this deque, or null if this deque is empty

Annotations
@Override
pollFirstback to summary
public E pollFirst()

Implements java.util.Deque.pollFirst.

Doc from java.util.Deque.pollFirst.

Retrieves and removes the first element of this deque, or returns null if this deque is empty.

Returns:E

the head of this deque, or null if this deque is empty

Annotations
@Override
pollLastback to summary
public E pollLast()

Implements java.util.Deque.pollLast.

Doc from java.util.Deque.pollLast.

Retrieves and removes the last element of this deque, or returns null if this deque is empty.

Returns:E

the tail of this deque, or null if this deque is empty

Annotations
@Override
popback to summary
public E pop()

Implements java.util.Deque.pop.

Doc from java.util.Deque.pop.

Pops an element from the stack represented by this deque. In other words, removes and returns the first element of this deque.

This method is equivalent to removeFirst().

Returns:E

the element at the front of this deque (which is the top of the stack represented by this deque)

Annotations
@Override
pushback to summary
public void push(E e)

Implements java.util.Deque.push.

Doc from java.util.Deque.push.

Pushes an element onto the stack represented by this deque (in other words, at the head of this deque) if it is possible to do so immediately without violating capacity restrictions, throwing an IllegalStateException if no space is currently available.

This method is equivalent to addFirst.

Parameters
e:E

the element to push

Annotations
@Override
removeback to summary
public E remove()

Implements java.util.Deque.remove.

Doc from java.util.Deque.remove.

Retrieves and removes the head of the queue represented by this deque (in other words, the first element of this deque). This method differs from poll() only in that it throws an exception if this deque is empty.

This method is equivalent to removeFirst().

Returns:E

the head of the queue represented by this deque

Annotations
@Override
removeback to summary
public boolean remove(Object o)

Overrides java.util.AbstractCollection.remove.

Implements java.util.Deque.remove, java.util.Collection.remove.

Doc from java.util.Deque.remove.

Removes the first occurrence of the specified element from this deque. If the deque does not contain the element, it is unchanged. More formally, removes the first element e such that Objects.equals(o, e) (if such an element exists). Returns true if this deque contained the specified element (or equivalently, if this deque changed as a result of the call).

This method is equivalent to removeFirstOccurrence(Object).

Parameters
o:Object

element to be removed from this deque, if present

Returns:boolean

true if an element was removed as a result of this call

Annotations
@Override
@SuppressWarnings:unchecked
removeback to summary
pack-priv boolean remove(E e)
removeAllback to summary
public boolean removeAll(Collection<?> c)

Overrides java.util.AbstractCollection.removeAll.

Implements java.util.Collection.removeAll.

Doc from java.util.Collection.removeAll.

Removes all of this collection's elements that are also contained in the specified collection (optional operation). After this call returns, this collection will contain no elements in common with the specified collection.

Parameters
c:Collection<?>

collection containing elements to be removed from this collection

Returns:boolean

true if this collection changed as a result of the call

Annotations
@Override
removeFirstback to summary
public E removeFirst()

Implements java.util.Deque.removeFirst.

Doc from java.util.Deque.removeFirst.

Retrieves and removes the first element of this deque. This method differs from pollFirst only in that it throws an exception if this deque is empty.

Returns:E

the head of this deque

Annotations
@Override
removeFirstOccurrenceback to summary
public boolean removeFirstOccurrence(Object o)

Implements java.util.Deque.removeFirstOccurrence.

Doc from java.util.Deque.removeFirstOccurrence.

Removes the first occurrence of the specified element from this deque. If the deque does not contain the element, it is unchanged. More formally, removes the first element e such that Objects.equals(o, e) (if such an element exists). Returns true if this deque contained the specified element (or equivalently, if this deque changed as a result of the call).

Parameters
o:Object

element to be removed from this deque, if present

Returns:boolean

true if an element was removed as a result of this call

Annotations
@Override
removeLastback to summary
public E removeLast()

Implements java.util.Deque.removeLast.

Doc from java.util.Deque.removeLast.

Retrieves and removes the last element of this deque. This method differs from pollLast only in that it throws an exception if this deque is empty.

Returns:E

the tail of this deque

Annotations
@Override
removeLastOccurrenceback to summary
public boolean removeLastOccurrence(Object o)

Implements java.util.Deque.removeLastOccurrence.

Doc from java.util.Deque.removeLastOccurrence.

Removes the last occurrence of the specified element from this deque. If the deque does not contain the element, it is unchanged. More formally, removes the last element e such that Objects.equals(o, e) (if such an element exists). Returns true if this deque contained the specified element (or equivalently, if this deque changed as a result of the call).

Parameters
o:Object

element to be removed from this deque, if present

Returns:boolean

true if an element was removed as a result of this call

Annotations
@Override
sizeback to summary
public int size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.Deque.size, java.util.Collection.size.

Doc from java.util.Deque.size.

Returns the number of elements in this deque.

Beware that, unlike in most collections, this method is NOT a constant-time operation.

Returns:int

the number of elements in this deque

Annotations
@Override
unlinkFirstback to summary
pack-priv E unlinkFirst()

Unlinks the non-null first element.

unlinkLastback to summary
pack-priv E unlinkLast()

Unlinks the non-null last element.

com.fasterxml.jackson.databind.util.internal back to summary

pack-priv abstract Class LinkedDeque.AbstractLinkedIterator

extends Object
implements Iterator<E extends Linked<E>>
Class Inheritance
  • java.lang.Object
  • com.fasterxml.jackson.databind.util.internal.LinkedDeque.AbstractLinkedIterator
All Implemented Interfaces
java.util.Iterator

Field Summary

Modifier and TypeField and Description
pack-priv E

Constructor Summary

AccessConstructor and Description
pack-priv
AbstractLinkedIterator(E
the initial element to begin traversal from
start
)

Creates an iterator that can can traverse the deque.

Method Summary

Modifier and TypeMethod and Description
pack-priv abstract E
computeNext()

Retrieves the next element to traverse to or null if there are no more elements.

public boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.

public E
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.

public void
remove()

Overrides default java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cursorback to summary
pack-priv E cursor

Constructor Detail

AbstractLinkedIteratorback to summary
pack-priv AbstractLinkedIterator(E start)

Creates an iterator that can can traverse the deque.

Parameters
start:E

the initial element to begin traversal from

Method Detail

computeNextback to summary
pack-priv abstract E computeNext()

Retrieves the next element to traverse to or null if there are no more elements.

hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the iteration has more elements

Annotations
@Override
nextback to summary
public E next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:E

the next element in the iteration

Annotations
@Override
removeback to summary
public void remove()

Overrides default java.util.Iterator.remove.

Doc from java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation). This method can be called only once per call to next.

The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.

The behavior of an iterator is unspecified if this method is called after a call to the forEachRemaining method.

Annotations
@Override