tip.node
Class NodeList<E extends Node>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.AbstractSequentialList<E>
              extended by java.util.LinkedList<E>
                  extended by 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

Constructor Summary
NodeList(Node parent, String name, boolean empty_allowed)
           
NodeList(Node parent, String name, boolean empty_allowed, Collection<? extends E> c)
           
 
Method Summary
 boolean add(E o)
           
 void add(int index, E o)
           
 boolean addAll(int index, Collection<? extends E> c)
           
 void addFirst(E o)
           
 void addLast(E o)
           
 void clear()
           
 Object clone()
           
 ListIterator<E> listIterator(int index)
           
 E remove(int index)
           
 boolean remove(Object o)
           
 E removeFirst()
           
 E removeLast()
           
 E set(int index, E o)
           
 void setAll(List<? extends E> list)
           
 String toString(Stringifier<E> stringifier)
          Returns a text representation using the stringifier.
 
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
 
Methods inherited from class java.util.AbstractSequentialList
iterator
 
Methods inherited from class java.util.AbstractList
equals, hashCode, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, isEmpty, iterator, listIterator, removeAll, retainAll, subList
 
Methods inherited from interface java.util.Deque
iterator
 

Constructor Detail

NodeList

public NodeList(Node parent,
                String name,
                boolean empty_allowed)

NodeList

public NodeList(Node parent,
                String name,
                boolean empty_allowed,
                Collection<? extends E> c)
Method Detail

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