class IntSequence { private: int *data; int capacity, // capacity of object (length of the array) count; // number of values currently in the Sequence bool walkInProgress; int walkPosition; // position of last value returned // if the object is full, increases its capacity void expandIfFull (); // copies the data from the other sequence into the sequence being operated // upon. assumes that there is adequate capacity. void copyFrom (const IntSequence &otherSequence); public: // constructs an empty sequence. IntSequence (); // copy constructor IntSequence (const IntSequence &otherSequence); // destructor ~IntSequence (); // adds a value to the sequence. has no effect if the value is already // in the sequence. throws an "overflow_error" if the value cannot be // added to the sequence. void add (int value); // removes the specified value from the sequence. returns true on success // (value existed) and false on failure (value did not exist) bool remove (int value); // removes all values from the sequence (makes the Sequence empty) void removeAll (); // returns true if the value exists in the sequence and false otherwise bool valueExists (int value) const; // returns the number of values in the sequence. int size () const { return count; } // returns the "ith" value in the sequence. int getValue (int i) const; // These two methods make it possible to "walk through" the values in a // sequence. The values in the sequence are returned in ascending // numerical order, in the order "startWalk" may // be called at any time. If returns true on success (value obtained) and // false on failure (sequence empty). "continueWalk" may only be called if // 1/. the sequence has not been modified since a walk was // begun by calling startWalk AND // 2/. the last call to startWalk or ContinueWalk returned true // If these conditions are not met, "contiinueWalk" throws a "range_error" // exception. It returns true on success (value obtained) and false on // failure (no more values). bool startWalk (int &value); bool continueWalk (int &value); // returns true iff the two sequences contain exactly the same values bool operator== (const IntSequence &otherSequence) const; // returns the intersection of two sequences IntSequence intersect (const IntSequence &otherSequence) const; // returns the union of two sequences. throws an "overflow_error" if the // union of the sequences is too large to be handled. IntSequence unionWith (const IntSequence &otherSequence) const; IntSequence& operator= (const IntSequence &otherSequence); };