import java.util.*;
import RunnerData;

public class RunnerHistory {
  Vector history;
  int type;
  
  RunnerHistory(int t) {
    history = new Vector();
    type = t;
  }
  
  void add (long t, double v) {
    add(t, v, v, v);
  }
  void add (long t, double v, double p, double m) {
    add(new RunnerData(t, v, p, m));
  }
  void add (RunnerData d){
    int ct;
    // Usually, this will be the newest, greatest element of all
	 // so we just want to add it at the end
	 if(history.size() == 0) {
	   history.addElement(d);
	   return;
	 }
	   
	 if(d.timestamp > ((RunnerData) history.lastElement()).timestamp){
	   history.addElement(d);
	   return;
	 }
    
    // Otherwise, find out where we fit.
	 for(ct=0;ct<history.size();ct++){
	   if(d.timestamp < ((RunnerData) history.elementAt(ct)).timestamp){
	     history.insertElementAt(d, ct);
	     return;
	   }
	 }
  }
}
