realized there were two print statements in regression testin different SESEs, breaks...
[IRC.git] / Robust / src / Analysis / MLP / SESELock.java
1 package Analysis.MLP;
2
3 import java.util.HashSet;
4 import java.util.Iterator;
5
6 public class SESELock {
7         
8         private HashSet<ConflictNode> conflictNodeSet;
9         private int id;
10         
11         public SESELock(){
12                 conflictNodeSet=new HashSet<ConflictNode>();
13         }
14         
15         public void addEdge(ConflictEdge edge){
16                 conflictNodeSet.add(edge.getVertexU());
17                 conflictNodeSet.add(edge.getVertexV());
18         }
19         
20         public int getID(){
21                 return id;
22         }
23         
24         public void setID(int id){
25                 this.id=id;
26         }
27         
28         public boolean containsConflictNode(ConflictNode node){
29                 
30                 return conflictNodeSet.contains(node);          
31                 
32         }
33         
34         
35         public boolean testEdge(ConflictEdge newEdge){
36                 
37                 
38                 if( !conflictNodeSet.contains(newEdge.getVertexU()) && !conflictNodeSet.contains(newEdge.getVertexV()) ){
39                         return false;
40                 }
41                 
42                 ConflictNode nodeToAdd=conflictNodeSet.contains(newEdge.getVertexU())?newEdge.getVertexV():newEdge.getVertexU();
43                 
44                 HashSet<ConflictNode> nodeSet=new HashSet<ConflictNode>(conflictNodeSet);
45
46                 for(Iterator edgeIter=nodeToAdd.getEdgeSet().iterator();edgeIter.hasNext();){
47                         ConflictEdge edge=(ConflictEdge)edgeIter.next();
48                         if(nodeSet.contains(edge.getVertexU())){
49                                 nodeSet.remove(edge.getVertexU());
50                         }else if(nodeSet.contains(edge.getVertexV())){
51                                 nodeSet.remove(edge.getVertexV());
52                         }
53                 }
54                 
55                 return nodeSet.isEmpty();
56                 
57         }
58         
59         public String toString(){
60                 String rtr="";
61                 
62                 for (Iterator<ConflictNode> iterator = conflictNodeSet.iterator(); iterator.hasNext();) {
63                         ConflictNode node = (ConflictNode) iterator.next();
64                         rtr+=" "+node;
65                 }
66                 
67                 return rtr;
68         }
69
70 }