/****************************************************************************** Lab #10 -- Interface file for type "Sequence" (chained implementation) ******************************************************************************/ #ifndef SEQUENCE_ #define SEQUENCE_ #include #include typedef double EType; /*----------------------------------------------------------------------------- Type "Sequence" represents an unordered sequence of N items (in positions 0 to N-1), where each item is of type "EType". Duplicate items are allowed. Type "EType" must support "operator=()" and "operator==()". -----------------------------------------------------------------------------*/ class Sequence { public: // Initialize the sequence // Sequence(); // De-initialize the sequence // ~Sequence(); // Re-initialize the sequence // void reset(); // Return status information // unsigned length() const { return Num; } bool is_empty() const { return Num == 0; } // Return the position of a specified item (unless it is not present) // unsigned find( const EType& X ) const; // Retrieve an item from position I (unless I is not valid) // bool retrieve( EType& X, unsigned I ) const; // Remove an item from position I (unless I is not valid) // bool remove( EType& X, unsigned I ); // Insert an item at position I (unless I is not valid) // bool insert( const EType& X, unsigned I ); private: struct Node { EType Item; Node * Next; }; unsigned Num; // Number of items in the sequence Node * Head; // Pointer to node at head of sequence // Disabled operations // Sequence( const Sequence& RHS ) { exit( 1 ); } Sequence& operator=( const Sequence& RHS ) { exit( 1 ); } }; #endif