package simulator;

import utils.*;
import java.util.*;

public class SimulatorEvent implements Comparable {
  public final double time;
  public final Processor proc;
  public final Object data;
  public final Symbol name;
  private final int uid;
  private static int nextuid = 0;

  SimulatorEvent(Processor p, double t, Symbol n, Object d) {
    this.proc=p;this.time=t;this.data=d;this.name=n;
    uid = nextuid;
    nextuid++;
  }

  // sortable by time
  // this needs more study to fireproof it against SortedSet's equals
  public int compareTo(Object o) {
    SimulatorEvent s = (SimulatorEvent)o;
    if(this.time < s.time) return -1; 
    else if(this.time > s.time) return 1; 
    else if(this.uid < s.uid) return -1;
    else if(this.uid > s.uid) return 1;
    else return 0;
  }
}
