package EDU.neu.ccs.demeter.tools.apstudio.graphedit;
import java.awt.*;
import java.io.*;
import java.util.*;
import EDU.neu.ccs.demeter.*;
import EDU.neu.ccs.demeter.common.tg.*;


import EDU.neu.ccs.demeter.*;
class PathSegment_List implements java.util.Enumeration, Cloneable {
  protected Nonempty_PathSegment_List first;
  public Nonempty_PathSegment_List get_first() { return first; }
  public void set_first(Nonempty_PathSegment_List new_first)
    { first = new_first; }
  PathSegment_List() { super(); }
  public PathSegment_List(Nonempty_PathSegment_List first) {
    super();
    set_first(first);
  }
  public static PathSegment_List parse(java.io.InputStream in) throws ParseException
    { return new Parser(in)._PathSegment_List(); }
  public static PathSegment_List parse(String s) {
    try { return parse(new java.io.ByteArrayInputStream(s.getBytes())); }
    catch (ParseException e) { throw new RuntimeException(e.toString()); }
  }
  void universal_trv0_bef(UniversalVisitor _v_) {
    _v_.before(this);
  }
  void universal_trv0_aft(UniversalVisitor _v_) {
    _v_.after(this);
  }
  void universal_trv0(UniversalVisitor _v_) {
    universal_trv0_bef(_v_);
    if (first != null) {
      _v_.before_first(this, first);
    first.universal_trv0(_v_);
      _v_.after_first(this, first);
    }
    universal_trv0_aft(_v_);
  }
  void toAllSubclasses_Program_trv_bef(ClassNameTranspVisitor cntv, EdgeVisitor aev) {  }
  void toAllSubclasses_Program_trv_aft(ClassNameTranspVisitor cntv, EdgeVisitor aev) {  }
  void toAllSubclasses_Program_trv(ClassNameTranspVisitor cntv, EdgeVisitor aev) {
    toAllSubclasses_Program_trv_bef(cntv, aev);
    if (first != null) {
    first.toAllSubclasses_Program_trv(cntv, aev);
    }
    toAllSubclasses_Program_trv_aft(cntv, aev);
  }
  void checkStars_ProgramBehavior_trv_bef(DummyVisitor dv) {  }
  void checkStars_ProgramBehavior_trv_aft(DummyVisitor dv) {  }
  void checkStars_ProgramBehavior_trv(DummyVisitor dv) {
    checkStars_ProgramBehavior_trv_bef(dv);
    if (first != null) {
    first.checkStars_ProgramBehavior_trv(dv);
    }
    checkStars_ProgramBehavior_trv_aft(dv);
  }
  void __trav_toGraph_PathDirective_trv_bef(__V_PathDirective_toGraph __v0) {  }
  void __trav_toGraph_PathDirective_trv_aft(__V_PathDirective_toGraph __v0) {  }
  void __trav_toGraph_PathDirective_trv(__V_PathDirective_toGraph __v0) {
    __trav_toGraph_PathDirective_trv_bef(__v0);
    if (first != null) {
    first.__trav_toGraph_PathDirective_trv(__v0);
    }
    __trav_toGraph_PathDirective_trv_aft(__v0);
  }

  private Nonempty_PathSegment_List tail;
  public void addElement(PathSegment e) { 
    checktail(); 
    if (tail == null) {
      first = new Nonempty_PathSegment_List(e,null); tail = first;
    } else {
	tail.set_next(new Nonempty_PathSegment_List(e,null)); tail = tail.get_next();
    }
  }

  public void push(PathSegment e) { first = new Nonempty_PathSegment_List(e,first); }

  public java.util.Enumeration elements() { return new PathSegment_List(first); } 

  public int size() {
    int i= 0;
    for (java.util.Enumeration e=elements(); e.hasMoreElements(); i++)
	e.nextElement();
    return i;
  }
  public boolean isEmpty() { return (first == null); }

  public boolean hasMoreElements() { return (first != null); }

  public Object nextElement() {
    PathSegment car = first.get_it();
    first = first.get_next();
    return (Object) car;
  }

  private void checktail() {
    if (tail == null && first != null) {
	tail = first;
	while (tail.get_next() != null) tail = tail.get_next();
    }
  }
  public boolean contains(PathSegment e) {
    java.util.Enumeration en = this.elements();
    while (en.hasMoreElements())
	if (e.equals((PathSegment) en.nextElement())) return true;
    return false;
  }
}

