1 17 18 package SOFA.SOFAnode.Util.DFSRChecker.node; 19 20 import java.util.Collection ; 21 import java.util.Iterator ; 22 import java.util.TreeSet ; 23 24 29 public class AtomicAction extends TreeSet implements Comparable { 30 31 32 36 public AtomicAction(Collection c) { 37 super(c); 38 } 39 40 44 public AtomicAction() {} 45 46 47 50 public int compareTo(Object o) { 51 if (o instanceof AtomicAction) { 52 AtomicAction other = (AtomicAction)o; 53 54 if (this.size() < other.size()) 55 return -1; 56 else if (this.size() > other.size()) 57 return 1; 58 59 else { 60 Iterator it1 = this.iterator(); 61 Iterator it2 = other.iterator(); 62 63 while (it1.hasNext()) { 64 Object o1 = it1.next(); 65 Object o2 = it2.next(); 66 67 int result = ((Comparable )o1).compareTo(o2); 68 if (result != 0) 69 return result; 70 } 71 72 return 0; 73 } 74 } 75 else 76 return -1; 77 } 78 79 80 } 81 | Popular Tags |