//Sequence.cpp ***************************************************************************** * FILE: Sequence.cpp * * CLASS PROVIDED: sequence (part of namespace CS256_Asgn3) * * See sequence.h for documentation * * * * LIBRARIES: cassert for assert( ) * * * * NAMESPACE CS256_Asgn3 * * * *****************************************************************************/ #include #include "sequence.h" using namespace std; namespace CS256_Asgn3 { // CONSTRUCTOR /************************************************************************** * Function: sequence() * * Constructor: creates an sequence. * * Preconditions: none. * * Postcondition: The sequence has been initialized as an empty sequence. * **************************************************************************/ sequence( ) { } // MODIFICATION MEMBER FUNCTIONS /************************************************************************** * Function: start() * * The first item in the sequence becomes the new current item. * * Preconditions: none. * * Postcondition: The first item on the sequence becomes the current * * item (but if the sequence is empty, then there is no current item). * **************************************************************************/ void start( ) { return; } /************************************************************************** * Function: advance() * * The next item in the sequence becomes the current item * * Precondtions: Precondition: is_item returns true. * * Postcondition: If the current item was already the last item in the * * sequence, then there is no longer any current item. Otherwise, the * * new current item is the item immediately after the original current * * item. * **************************************************************************/ void advance( ) { return; } /************************************************************************** * Function: insert(const value_type& entry) * * 'entry' is added to the sequence before the current item. * * Precondition: size( ) < CAPACITY. * * Postcondition: A new copy of entry has been inserted in the sequence * * before the current item. If there was no current item, then the new * * entry has been inserted at the front of the sequence. In either case,* * the newly inserted item is now the current item of the sequence. * **************************************************************************/ void insert(const value_type& entry) { return; } /************************************************************************** * Function: attach(const value_type& entry) * * 'entry' is added to the sequence after the current item. * * Precondition: size( ) < CAPACITY. * * Postcondition: A new copy of entry has been attached in the sequence * * after the current item. If there was no current item, then the new * * entry has been attached to the end of the sequence. In either case, * * the newly inserted item is now the current item of the sequence. * **************************************************************************/ void attach(const value_type& entry) { return; } /************************************************************************** * Function: remove_current() * * The current item is taken out of the sequence * * Precondition: is_item returns true. * * Postcondition: The current item has been removed from the sequence, * * and the item after this (if there is one) is now the new current item * **************************************************************************/ void remove_current( ) { return; } // CONSTANT MEMBER FUNCTIONS /************************************************************************** * Function: size() const * * Returns how many items are in the sequence. * * Precondition: none. * * Postcondition: Return value is the number of items in the sequence. * **************************************************************************/ size_type size( ) const { return size_t number; } /************************************************************************** * Function: is_item() * * True if current points to an item. * * Precondition: none. * * Postcondition: A true return value indicates that there is a valid * * "current" item that may be retrieved by activating the current * * member function (listed below). A false return value indicates that * **************************************************************************/ bool is_item( ) const { return true; } /************************************************************************** * Function: current() * * Returns what data type the current item is. * * Precondition: is_item( ) returns true. * * Postcondition: The item returned is the current item in the sequence. * **************************************************************************/ value_type current( ) const { return value_type; } }