// evlist.h: the EventList class, representing the list of events waiting
// to happen. The "list" is in fact a priority queue.

// There is only one object of the class EventList in this program.

#ifndef _EVLIST_H
#define _EVLIST_H

#include "event.h"

class EventList {
private:

   // ListItem: the type for objects stored in the event list.
   struct ListItem {
      // The event list is a linked list, so each item contains a data field
      // and a "next item" field. This is just a simple record structure, so
      // we'll allow outsiders to access the fields directly instead of using
      // get and set methods.
      Event *data;
      ListItem *next;
   };

   ListItem *firstEvent;

public:

   // Constructor.
   // We initialize firstEvent to null (though it would be done automatically)
   // to emphasize that the list is initially empty.
   EventList () : firstEvent (0) { }

   // insert: add an event e to the event list in the appropriate place,
   // prioritized by time.
   void insert (Event *e);

   // takeNextEvent: remove the item at the head of the event list and
   // return it.
   Event *takeNextEvent ();
};

#endif
