(Latest Revision: Sun Apr 15 02:38:45 PDT 2001 )
// ******************************************************** // Header file deque.h for the ADT deque. // Pointer-based implementation. // ******************************************************** typedef double dequeItemType ; // The deque is implemented as a circular doubly linked list // with one external pointer to the back of the deque. struct dequeNode; typedef dequeNode* ptrType; class dequeClass { public: // constructors and destructor: dequeClass(); // default constructor ~dequeClass(); // destructor // deque operations: int Length() const; // Determines the length of a deque. // Precondition: None. // Postcondition: Returns the number of items // that are currently in the deque. bool IsEmpty() const; // Determines whether a deque is empty. // Precondition: None. // Postcondition: Returns true if the deque is empty; // otherwise returns false. void AddInFront(dequeItemType NewItem, bool& Success); // Adds an item to the front of a deque. // Precondition: NewItem is the item to be added. // Postcondition: If insertion was successful, NewItem // is at the front of the deque and Success is true; // otherwise Success is false. void AddInRear(dequeItemType NewItem, bool& Success); // Adds an item to the rear of a deque. // Precondition: NewItem is the item to be added. // Postcondition: If insertion was successful, NewItem // is at the rear of the deque and Success is true; // otherwise Success is false. void TakeOutFront(dequeItemType& DequeFront, bool& Success); // Retrieves and removes the front of a deque. // Precondition: None. // Postcondition: If the deque was not empty, DequeFront // contains the item that was at the front of the Deque, // the item is removed, and Success is true. However, if the // deque was empty, deletion is impossible, DequeFront is // unchanged, and Success is false. void TakeOutRear(dequeItemType& DequeRear, bool& Success); // Retrieves and removes the rear of a deque. // Precondition: None. // Postcondition: If the deque was not empty, DequeRear // contains the item that was at the rear of the Deque, // the item is removed, and Success is true. However, if the // deque was empty, deletion is impossible, DequeRear is // unchanged, and Success is false. void Print() const; // Prints the contents of the Deque in front-to-back order. // (Prints to standard output.) // Does nothing if the Deque is empty. // Precondition: None // Postcondition: Deque is unchanged. private: ptrType BackPtr; int Size ; }; // end class // End of header file.