public ExternalEvent nextEvent(){
  if (queue.size() == 0) {
    return new ExternalEvent(Double.MAX_VALUE);
  }
  ExternalEvent ee=queue.get(nextEventIndex);
  nextEventIndex++;
  if (nextEventIndex >= queue.size()) {
    queue=readEvents(nrofPreload);
    nextEventIndex=0;
  }
  return ee;
}

public ExternalEvent nextEvent ( ) { if ( queue . size ( ) == 0 ) { return new ExternalEvent ( Double . MAX_VALUE ) ; } ExternalEvent ee = queue . get ( nextEventIndex ) ; nextEventIndex ++ ; if ( nextEventIndex >= queue . size ( ) ) { queue = readEvents ( nrofPreload ) ; nextEventIndex = 0 ; } return ee ; }
returns the next event in the queue or externalevent with time of double . max_value if there are no events left
