- public Tree(Token.Location loc, T head) { this(loc, head, null); }
- public Tree(Token.Location loc, T head, Tree<T>[] children) {
- this.location = loc;
- this.head = head;
- Tree<T>[] children2 = children==null ? new Tree[0] : new Tree[children.length];
- if (children != null) System.arraycopy(children, 0, children2, 0, children.length);
- this.children = children2;
+ /** the element at the head of the tree */
+ public NodeType head() { return ihead; }
+ public NodeType getHead() { return ihead; }
+
+ /** the tree's children */
+ public Iterable<Tree<NodeType>> children() { return this; }
+
+ /** the tree's children */
+ public Iterator<Tree<NodeType>> iterator() { return new ArrayIterator(children); }
+
+ /** get the <tt>i</t>th child */
+ public Tree<NodeType> child(int i) { return children[i]; }
+
+ /** get the input region that this tree was parsed from */
+ public Input.Region getRegion() { return location; }
+
+ public Tree(Input.Region loc, NodeType head) {
+ location = loc;
+ ihead = head;
+ children = emptyTree;