tip.node
Class NodeList<E extends Node>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.AbstractSequentialList<E>
java.util.LinkedList<E>
tip.node.NodeList<E>
- All Implemented Interfaces:
- Serializable, Cloneable, Iterable<E>, Collection<E>, Deque<E>, List<E>, Queue<E>, Stringifiable<E>
public class NodeList<E extends Node>
- extends LinkedList<E>
- implements Stringifiable<E>
A list of AST nodes where all operations preserve the
single-parent property of the AST.
A node list is always a child list of some parent node.
When a node is added to the list (through the collection constructor,
the add
, addFirst
, addLast
,
addAll
or set
methods of the list or
the add
or set
methods of the iterator),
it is removed from its original parent (if it has one) and its parent
is set to the node containing the node list.
When a node is removed from the list (through the remove
,
removeFirst
, removeLast
, clear
or
set
methods of the list or the remove
or
set
methods of the iterator), its parent is set to
null
.
Beware that if the add
or set
method of the
iterator is called with a node which is already in the list (except for a
set
call replacing a node by itself), the iterator
will be invalidated, so any subsequent iterator operation will throw a
ConcurrentModificationException
.
- Author:
- Aske Simon Christensen, aske@brics.dk
- See Also:
- Serialized Form
Methods inherited from class java.util.LinkedList |
addAll, contains, descendingIterator, element, get, getFirst, getLast, indexOf, lastIndexOf, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, pop, push, remove, removeFirstOccurrence, removeLastOccurrence, size, toArray, toArray |
NodeList
public NodeList(Node parent,
String name,
boolean empty_allowed)
NodeList
public NodeList(Node parent,
String name,
boolean empty_allowed,
Collection<? extends E> c)
add
public boolean add(E o)
- Specified by:
add
in interface Collection<E extends Node>
- Specified by:
add
in interface Deque<E extends Node>
- Specified by:
add
in interface List<E extends Node>
- Specified by:
add
in interface Queue<E extends Node>
- Overrides:
add
in class LinkedList<E extends Node>
addFirst
public void addFirst(E o)
- Specified by:
addFirst
in interface Deque<E extends Node>
- Overrides:
addFirst
in class LinkedList<E extends Node>
addLast
public void addLast(E o)
- Specified by:
addLast
in interface Deque<E extends Node>
- Overrides:
addLast
in class LinkedList<E extends Node>
remove
public boolean remove(Object o)
- Specified by:
remove
in interface Collection<E extends Node>
- Specified by:
remove
in interface Deque<E extends Node>
- Specified by:
remove
in interface List<E extends Node>
- Overrides:
remove
in class LinkedList<E extends Node>
removeFirst
public E removeFirst()
- Specified by:
removeFirst
in interface Deque<E extends Node>
- Overrides:
removeFirst
in class LinkedList<E extends Node>
removeLast
public E removeLast()
- Specified by:
removeLast
in interface Deque<E extends Node>
- Overrides:
removeLast
in class LinkedList<E extends Node>
clear
public void clear()
- Specified by:
clear
in interface Collection<E extends Node>
- Specified by:
clear
in interface List<E extends Node>
- Overrides:
clear
in class LinkedList<E extends Node>
clone
public Object clone()
- Overrides:
clone
in class LinkedList<E extends Node>
remove
public E remove(int index)
- Specified by:
remove
in interface List<E extends Node>
- Overrides:
remove
in class LinkedList<E extends Node>
setAll
public void setAll(List<? extends E> list)
addAll
public boolean addAll(int index,
Collection<? extends E> c)
- Specified by:
addAll
in interface List<E extends Node>
- Overrides:
addAll
in class LinkedList<E extends Node>
add
public void add(int index,
E o)
- Specified by:
add
in interface List<E extends Node>
- Overrides:
add
in class LinkedList<E extends Node>
set
public E set(int index,
E o)
- Specified by:
set
in interface List<E extends Node>
- Overrides:
set
in class LinkedList<E extends Node>
listIterator
public ListIterator<E> listIterator(int index)
- Specified by:
listIterator
in interface List<E extends Node>
- Overrides:
listIterator
in class LinkedList<E extends Node>
toString
public String toString(Stringifier<E> stringifier)
- Description copied from interface:
Stringifiable
- Returns a text representation using the
stringifier
.
- Specified by:
toString
in interface Stringifiable<E extends Node>
- Parameters:
stringifier
- the Stringifier
used
- Returns:
- a text representation using the
stringifier