//-------------------------------------------------------------------------------------------------------------------- // Header for the definition of a "flexible" vector whose size is dynamic and default entries are zeroes. //-------------------------------------------------------------------------------------------------------------------- #include // list class and operations. using std::list; const char FETCH = '?'; // Determines value set to subscript for vector. const char ASSIGN = '='; // Sets subscript value to input value for vector. const char STATUS = 's'; // Returns status of specified vector const char COMMENT = '*'; // Comment -- rest of line ignored. const int MAXC = 5; // Maximum # of arguments in command+1. const int MAXV = 3; // Maximum # of vectors in program. class Pair { int key; // Key for the record pair. int value; // Associated integer value. public: Pair(int k, int v) { key = k; value = v; } Pair() : key(0), value(0) {} int getKey() {return key;}; // Return the subscript. int & getValue() {return value;}; // Return the value associated with key. }; class FlexVec { private: list vlist; // List to contain information. public: ~FlexVec(); int & operator[ ](int subscript); // Overloaded subscripting operator. // Returns the number of non-zero entries, and the range of indices that contain non-zero values. void Status(int &numEntries, int &minIndex, int &maxIndex); }; // FlexVec