/* * Copyright (c) 2002 by Cliff Green. All rights reserved. Individual files * may be covered by other copyrights (as noted in the file itself). * * Redistribution and use in source and binary forms are permitted * provided that this entire copyright notice is duplicated in all such * copies. * * This software is provided "as is" and without any expressed or implied * warranties, including, without limitation, the implied warranties of * merchantibility and fitness for any particular purpose. */ //---------------------------------------------------------------------- // Source file: dict.h // Written by: Cliff Green, 2002 // Compiler: Metrowerks CodeWarrior Pro 6, g++ 3.0.4 // History: // Modified: Mar. 5, 2002 // By: Cliff Green // Comments: Dictionary class header file. //---------------------------------------------------------------------- // This commentheader supports documentation tools such as Doc++ and // Doxygen: http://www.doxygen.org/ //---------------------------------------------------------------------- /// Dictionary class declaration. /** * The data structure design in this class works for an intro look at * encapsulation and public interfaces. In particular, the use of the * multimap is meant as a glimpse to late Intro / early Intermediate * usage. There are also other (mostly superior) ways to implement a * container for these needs, but this code is simple for beginning C++ * instruction. */ #ifndef DICT_H #define DICT_H #include "word.h" #include #include #include class Dictionary { public: Dictionary () : mWords(), mSortState (UNSORTED), mSdxMap() { } // default ctor, starting empty // ~Dictionary (); // dtor implicit (generated by compiler, if needed) bool insert (Word const& ); // insert an entry bool search (Word const& ); // search for entry, true if exists, false otherwise WordVec const getSameSdx(Word const&) const; private: enum SortStates { UNSORTED, SORTED }; WordVec mWords; SortStates mSortState; typedef std::multimap SdxMap; SdxMap mSdxMap; Dictionary (Dictionary const& ); // private - disable copy ctor Dictionary& operator= (Dictionary const&); // disable copy assign op }; #endif