X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=Robust%2Fsrc%2FAnalysis%2FSSJava%2FNodeTupleSet.java;h=c8e80cb75513f71c74e2347a9cf3c1e2d95a239c;hb=9dfdca00acf795117136425841493a1b0f036f10;hp=6850960485f676def5fdab549dd21111e98d8c01;hpb=1bf00baead0bc7e05945fe5649f9d92afadae081;p=IRC.git diff --git a/Robust/src/Analysis/SSJava/NodeTupleSet.java b/Robust/src/Analysis/SSJava/NodeTupleSet.java index 68509604..c8e80cb7 100644 --- a/Robust/src/Analysis/SSJava/NodeTupleSet.java +++ b/Robust/src/Analysis/SSJava/NodeTupleSet.java @@ -1,51 +1,101 @@ package Analysis.SSJava; +import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; +import java.util.List; import java.util.Set; import IR.Descriptor; public class NodeTupleSet { - private Set> set; + private ArrayList> list; + + private ArrayList> globalLocTupleList; public NodeTupleSet() { - set = new HashSet>(); + list = new ArrayList>(); + globalLocTupleList = new ArrayList>(); } public void addTuple(NTuple tuple) { - // need to add additional elements because we need to create edges even from - // the base - // for example, if we have input , we need to add additional element - // and to the set + for (Iterator iterator = list.iterator(); iterator.hasNext();) { + NTuple t = (NTuple) iterator.next(); + if (t.equals(tuple)) { + return; + } + } + + list.add(tuple); + } + + public void addGlobalFlowTuple(NTuple tuple) { + globalLocTupleList.add(tuple); + } - // NTuple cur = new NTuple(); - // for (int i = 0; i < tuple.size(); i++) { - // Descriptor d = tuple.get(i); - // cur.add(d); - // set.add(new NTuple(cur)); - // } + public Iterator> globalIterator() { + return globalLocTupleList.iterator(); + } - set.add(tuple); + public void removeTuple(NTuple tuple) { + list.remove(tuple); } public Iterator> iterator() { - return set.iterator(); + return list.iterator(); } public String toString() { - return set.toString(); + String str = list.toString(); + + if (globalLocTupleList.size() > 0) { + str += " GlobalFlow=" + globalLocTupleList.toString(); + } + + return str; } public Set> getSet() { + Set> set = new HashSet>(); + set.addAll(list); return set; } public void addTupleSet(NodeTupleSet in) { if (in != null) { - set.addAll(in.getSet()); + for (Iterator iterator = in.iterator(); iterator.hasNext();) { + NTuple inTuple = (NTuple) iterator.next(); + addTuple(inTuple); + } } } + + public int size() { + return list.size(); + } + + public void clear() { + list.clear(); + } + + public int globalLocTupleSize() { + return globalLocTupleList.size(); + } + + private void setGlobalLocTupleList(ArrayList> in) { + globalLocTupleList = in; + } + + private void setDescTupleList(ArrayList> in) { + list = in; + } + + public NodeTupleSet clone() { + NodeTupleSet set = new NodeTupleSet(); + set.setDescTupleList((ArrayList>) list.clone()); + set.setGlobalLocTupleList((ArrayList>) globalLocTupleList.clone()); + return set; + } }