// Chap 7, pp 339 - 341
// Rename this file as EL.h
//**********************************************************
// Header file EL.h for ADT event list.
// The event list contains events that are sorted by the
// time of the event. There are two kinds of events:
// Arrival: Person enters the line. Event is represented
// by the arrival time and transaction time.
// Departure: Person completes transaction and leaves the
// line. Event is represented by the departure
// time.
//**********************************************************
#include // defines NULL
#include
#include "boolean.h"
enum eventKind {A, D}; // 2 kinds of events
struct event
{
eventKind WhichEvent; // A (arrival) or D (departure)
int Time; // time of event
int TransTime; // transaction time; used
// for arrival events only
// constructors:
event();
event(eventKind KindOfEvent, int EventTime,
int TransactionTime);
}; // end struct
struct eventNode; // defined in implementation file
typedef eventNode* eventPtrType;
class eventListClass
{
public:
// constructors and destructor:
eventListClass();
eventListClass(const eventListClass& E);
~eventListClass();
// event list operations:
boolean EventListIsEmpty();
// Determines whether the event list is empty.
// Precondition: The constructor has been called.
// Postcondition: Returns TRUE if the event list is
// empty, otherwise returns FALSE.
void InsertEvent(event NewEvent, boolean& Success);
// Inserts an event into the event list in its proper
// order by time.
// Precondition: The constructor has been called.
// NewEvent is the event to be added to the list.
// Postcondition: If insertion is successful, NewEvent is
// added to the event list such that times are ordered
// (if events have the same times, arrival events come
// before departure events) and Success is TRUE.
// Otherwise, Success is FALSE.
void DeleteEvent(boolean& Success);
// Deletes the first event in the event list.
// Precondition: The constructor has been called.
// Postcondition: If deletion is successful, the first
// event is deleted and Success is TRUE. Otherwise, the
// event list is unchanged and Success is FALSE.
void RetrieveEvent(event& FirstEvent, boolean& Success);
// Retrieves the first event in the event list.
// Precondition: The constructor has been called.
// Postcondition: If retrieval is successful, the first
// event is copied into FirstEvent and Success is TRUE.
// Otherwise, FirstEvent is unchanged and Success is
// FALSE.
private:
eventPtrType EL; // pointer to linked event list
}; // end class
// End of header file.
               (
geocities.com/siliconvalley/program/2864/ds)                   (
geocities.com/siliconvalley/program/2864)                   (
geocities.com/siliconvalley/program)                   (
geocities.com/siliconvalley)