private ITmfTrace[] fTraces = new ITmfTrace[0];
private TmfContext[] fContexts;
private TmfEvent[] fEvents;
- private int lastTrace;
+ private int lastTraceRead;
// ------------------------------------------------------------------------
// Constructors
}
}
- setLocation(new TmfExperimentLocation(locations, ranks));
+ setLocation(new TmfExperimentLocation(new TmfLocationArray(locations), ranks));
setRank(rank);
- lastTrace = NO_TRACE;
+ lastTraceRead = NO_TRACE;
}
public TmfExperimentContext(ITmfTrace[] traces) {
public TmfExperimentContext(TmfExperimentContext other) {
this(other.fTraces, other.cloneContexts());
fEvents = other.fEvents;
- setLocation(other.getLocation().clone());
+ if (other.getLocation() != null)
+ setLocation(other.getLocation().clone());
setRank(other.getRank());
- setLastTrace(other.lastTrace);
+ setLastTrace(other.lastTraceRead);
}
private TmfContext[] cloneContexts() {
}
public int getLastTrace() {
- return lastTrace;
+ return lastTraceRead;
}
public void setLastTrace(int newIndex) {
- lastTrace = newIndex;
+ lastTraceRead = newIndex;
}
+ // ------------------------------------------------------------------------
+ // Object
+ // ------------------------------------------------------------------------
+
+ @Override
+ public int hashCode() {
+ int result = 17;
+ for (int i = 0; i < fTraces.length; i++) {
+ result = 37 * result + fTraces[i].hashCode();
+ result = 37 * result + fContexts[i].hashCode();
+ }
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (!(other instanceof TmfExperimentContext)) {
+ return false;
+ }
+ TmfExperimentContext o = (TmfExperimentContext) other;
+ boolean isEqual = true;
+ int i = 0;
+ while (isEqual && i < fTraces.length) {
+ isEqual &= fTraces[i].equals(o.fTraces[i]);
+ isEqual &= fContexts[i].equals(o.fContexts[i]);
+ i++;
+ }
+ return isEqual;
+ }
+
}