package CSU670_Plugin.gen;
import edu.neu.ccs.demeter.dj.*;
import edu.neu.ccs.demeter.aplib.cd.ClassDefVisitor;
import edu.neu.ccs.demeter.aplib.cd.ClassDef;
import java.io.*;
import java.util.*;

import edu.neu.ccs.demeter.*;
class Intersection extends BinaryOp {
  public Intersection() {
    super();
  }
  public static Intersection parse(java.io.Reader in) throws ParseException { return new Parser(in)._Intersection(); }
  public static Intersection parse(java.io.InputStream in) throws ParseException { return new Parser(in)._Intersection(); }
  public static Intersection parse(String s) {
    try { return parse(new java.io.StringReader(s)); }
    catch (ParseException e) {
      throw new RuntimeException(e.toString());
    }
  }

    List apply(List args){
        if(args.size()==0) return new ArrayList();
        Iterator i = args.iterator();
        List r = new LinkedList((List)i.next());
        while(i.hasNext()){
        	List l = (List)i.next();
        	for(Iterator ii = r.iterator(); ii.hasNext();){
        		if(!l.contains(ii.next())) ii.remove();
        	}	  		
        }
        return r;
    }

  void universal_trv0_bef(UniversalVisitor _v_) {
    super.universal_trv0_bef(_v_);
    ((UniversalVisitor) _v_).before(this);
  }

  void universal_trv0_aft(UniversalVisitor _v_) {
    ((UniversalVisitor) _v_).after(this);
    super.universal_trv0_aft(_v_);
  }

  void universal_trv0(UniversalVisitor _v_) {
    universal_trv0_bef(_v_);
    super.universal_trv0(_v_);
    universal_trv0_aft(_v_);
  }

}
