public class ClassNode extends GraphNode implements Cloneable {
private int uid;
+ private int cid;
private static int nodeID=0;
+ private static int colorID = 1;
+ private static Hashtable<ClassDescriptor, Integer> cd2cid =
+ new Hashtable<ClassDescriptor, Integer>();
private final ClassDescriptor cd;
private ScheduleNode sn;
private boolean sorted = false;
private boolean clone = false;
- private int transTime;
+ private long transTime;
/** Class constructor
* @param cd ClassDescriptor
* @param fStates
*/
- public ClassNode(ClassDescriptor cd, Vector<FlagState> fStates) {
+ public ClassNode(ClassDescriptor cd,
+ Vector<FlagState> fStates) {
this.cd=cd;
this.flagStates = fStates;
this.sn = null;
this.uid=ClassNode.nodeID++;
+ // TODO: potential bug here
+ // DO NOT consider splitting a class node here.
+ // need to fix: 1. when a class node is splitted, the pieces should have
+ // different cid
+ // 2. when two pieces merged, it should have right cid as have
+ // never been splitted
+ // 3. NOTE: a piece could be splitted further
+ if(this.cd2cid.containsKey(cd)) {
+ this.cid = this.cd2cid.get(cd);
+ } else {
+ this.cid = ClassNode.colorID++;
+ this.cd2cid.put(this.cd, this.cid);
+ }
this.transTime = 0;
}
- public int getTransTime() {
+ public long getTransTime() {
return this.transTime;
}
- public void setTransTime(int transTime) {
+ public void setTransTime(long transTime) {
this.transTime = transTime;
}
return uid;
}
+ public int getCid() {
+ return cid;
+ }
+
public ScheduleNode getScheduleNode() {
return this.sn;
}
if (o instanceof ClassNode) {
ClassNode fs=(ClassNode)o;
if ((fs.getClassDescriptor()!= cd) ||
+ (fs.getuid()!= uid) ||
+ (fs.getCid()!= cid) ||
(fs.isSorted() != sorted) ||
(fs.clone != this.clone) ||
(fs.transTime != this.transTime)) {
}
public int hashCode() {
- return cd.hashCode()^Boolean.toString(sorted).hashCode()^Boolean.toString(clone).hashCode()^
- transTime^flagStates.hashCode();
+ return cd.hashCode()^uid^cid^Boolean.toString(sorted).hashCode()^
+ Boolean.toString(clone).hashCode()^(int)transTime^flagStates.hashCode();
}
public String getLabel() {
ClassNode o = null;
try {
o = (ClassNode) super.clone();
- } catch(CloneNotSupportedException e){
+ } catch(CloneNotSupportedException e) {
e.printStackTrace();
}
o.uid = ClassNode.nodeID++;
+ o.cid = this.cid;
o.clone = true;
return o;
}