// StringToIntTable.h // // Written 19 Feb 1996 by Max Hailperin . // // Defines interface for a class of string to integer location mappings. #ifndef _STRING_TO_INT_TABLE_H #define _STRING_TO_INT_TABLE_H class StringToIntTableRep; class StringToIntTable{ public: StringToIntTable(int initialValue = 0); ~StringToIntTable(); /* notes on the [] (access) operator: 1) a reference to an integer storage location associated with the string is always returned; if the string was previously not in the table, it is inserted with a new integer location associated with it that is initialized to the initialValue provided when the table was constructed and the reference returned is to that location, while if the string was already in the table a reference to the pre-existing location is returned; the location can of course be updated by assignment 2) the table doesn't retain any pointer to the string, even in the case that the string is a new one and hence is inserted; instead the table makes its own copy so that the caller is free to change the contents of the string or reclaim its storage after the call to operator[] without harming the table */ int& operator[](const char *string); private: StringToIntTableRep *rep; }; #endif