#include #include #include using namespace std; #include // ========================================================================= const int DEFAULT_SIZE = 4096; class Dictionary { public: Dictionary(void) { InitArray(DEFAULT_SIZE); }; Dictionary(int Size) { InitArray(Size); }; ~Dictionary(); int& operator[](string key); void Delete(string key); int Length() { return count; }; void Print(); private: // data string *keys; int *values; int size; int count; int increment; // functions void InitArray(int Size); bool position(string key, int &pos); void ChangeSize(int size_change); }; // ------ private functions ------ void Dictionary::InitArray(int Size) { size = Size; count = 0; keys = new string[size]; values = new int[size]; increment = size/4>0 ? size/4 : 2; } bool Dictionary::position(string key, int &pos) { int l=0, u=count-1; if( !count || key=pos;i--){ keys[i+1] = keys[i]; values[i+1] = values[i]; } } // insert the element in the right place keys[pos] = key; values[pos] = 0; count++; if( count == size ) ChangeSize(increment); } return values[pos]; } void Dictionary::Print() { for(int i=0;i remove it from the array for(int i=pos+1;i>word ) words[word]++; cout<