private class ScopedList.NodeList
extends java.util.AbstractSequentialList<E>
List
interface to provide a read-only view of this scope's
elements.
A private API is provided to allow add and removal operations by the enclosing class.
Modifier and Type | Class and Description |
---|---|
private class |
ScopedList.NodeList.Iter
Implementation of a read-only list iterator for a node list.
|
Modifier and Type | Field and Description |
---|---|
private ScopedList.Node<E> |
head
Head of the list
|
private int |
size
Size of the list
|
private ScopedList.Node<E> |
tail
Tail of the list
|
Constructor and Description |
---|
NodeList()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
private void |
addNode(ScopedList.Node<E> node)
Add the given node to the tail of the list.
|
java.util.ListIterator<E> |
listIterator(int cursor)
Obtain a read-only list iterator on this scope's elements.
|
private int |
removeAllElements(java.util.List<E> elements)
Remove all nodes which match the elements in the given list, using an algorithm that is
biased toward an assumption that the given
elements are in the same order as the
nodes in the node list. |
private boolean |
removeElement(E element)
Remove the node which contains the given element, if any.
|
private ScopedList.Node<E> |
removeElement(ScopedList.Node<E> begin,
ScopedList.Node<E> end,
E element)
Remove the node which contains the given element, if any.
|
int |
size()
Get the number of elements in this list.
|
add, addAll, get, iterator, remove, set
add, clear, equals, hashCode, indexOf, lastIndexOf, listIterator, removeRange, subList
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
private ScopedList.Node<E> head
private ScopedList.Node<E> tail
private int size
public java.util.ListIterator<E> listIterator(int cursor)
UnsupportedOperationException
.listIterator
in interface java.util.List<E>
listIterator
in class java.util.AbstractSequentialList<E>
cursor
- Zero-based cursor position at which to begin the iteration.java.lang.IndexOutOfBoundsException
- if cursor < 0 || cursor > size()
public int size()
private void addNode(ScopedList.Node<E> node)
node
- Node to be added.private boolean removeElement(E element)
This operation affects both the state of this node list (head, tail, size), the state of the enclosing list (head and tail, but not size), the state of the given node, and the state of surrounding nodes. If the element is found, its node's links to other nodes are broken, and those nodes' links are fixed up to reference one another.
element
- Element whose containing node is to be removed from the list.true
if the element was removed;
false
if the element was not found.private int removeAllElements(java.util.List<E> elements)
elements
are in the same order as the
nodes in the node list.
For each node removed, this operation affects both the state of this node list (head, tail, size), the state of the enclosing list (head and tail, but not size), the state of the given node, and the state of surrounding nodes. If an element is found, its node's links to other nodes are broken, and those nodes' links are fixed up to reference one another.
elements
- Elements to be removed from the list.private ScopedList.Node<E> removeElement(ScopedList.Node<E> begin, ScopedList.Node<E> end, E element)
element
is conducted by scanning forward from the given start
node to the given end
node.
This operation affects both the state of this node list (head, tail, size), the state of the enclosing list (head and tail, but not size), the state of the given node, and the state of surrounding nodes. If the element is found, its node's links to other nodes are broken, and those nodes' links are fixed up to reference one another.
begin
- Node at which to start scanning for the given element.end
- Node at which to stop scanning for the given element.element
- Element whose containing node is to be removed from the list.true
if the element was removed;
false
if the element was not found.