import java.util.*; //********************************************* // class EventQueue: written by Hyunyoung Lee // // Extend class Vector, to have class Event // as the type of each element. //********************************************* class EventQueue extends Vector { private Event e; public EventQueue () { new Vector(); } // constructor EventQueue //*************************************** // method lookup // // Lookup i'th element in the vector, and // returns it as Event type. //*************************************** public Event lookup (int i) { e = (Event) elementAt(i); return e; } // method lookup //************************************ // method deQ // // Remove and return the first element // as Event type, in the vector. //************************************ public Event deQ () { e = (Event) firstElement(); removeElementAt(0); return e; } // method deQ //************************************ // method enQ // // Add the event e as the last element // of the vector. //************************************ public void enQ (Event e) { addElement(e); } // method enQ //******************************************* // method insert // // Insert events in the event queue according // to its scheduled occurrence time. //******************************************* public void insert (Event e) { int i, n; n = size(); for (i = 0; i < n; i++) { if (((Event) elementAt(i)).getOccurTime() > e.getOccurTime()){ insertElementAt(e, i); return; } } if (i == size()) { addElement(e); } } // method insert } // end of class EventQueue