////////////////////////////////////////////////////////////////// // // wordlist.h // // Started by Jeff Ondich on 4/16/98 // Last modified 4/17/98 // // This is the interface for a class that maintains an // alphabetized list of words and the number of times // they have been "added" to the list. This class will // be used to count the number of times each word occurs // in a file, and to report the word counts in alphabetical // order. // ////////////////////////////////////////////////////////////////// #include const int kMaxListSize = 200; class WordList { private: string mTheWords[kMaxListSize]; int mOccurrenceCount[kMaxListSize]; int mListSize; public: WordList( void ); void AddWord( const string& newWord ); void PrintList( void ); int Size( void ); bool IsEmpty( void ); bool IsFull( void ); }; // The following are descriptions of the member functions of // the WordList class. // // WordList( void ) // This constructor initializes the WordList to // empty. // // void AddWord( const string& newWord ) // If newWord is not yet contained in the word list, // then AddWord shifts words down to make room for // newWord in its proper alphabetical position and // puts newWord into that position and sets the // corresponding occurrence count to 1. On the other // hand, if newWord is already in the list, AddWord // just adds 1 to the corresponding occurrence count. // All words are converted to lower-case before being // compared to other words or installed in the list. // If the list is full and newWord is not already // in the list, AddWord does nothing. // // void PrintList( void ) // PrintList prints out the words in the list along // with their occurrence counts. // // int Size( void ) // Size returns the number of words in the list. // // bool IsFull( void ) // IsFull returns true if the list can hold no more // words, and false otherwise. // // bool IsEmpty( void ) // IsEmpty returns true if the list is empty, and false // otherwise.