/*
 * 2004 Utah High School Programming Contest, University of Utah
 * Take-Home Problem
 *
 * Dictionary.hpp
 *
 * This file contains the definition of the Dictionary class.
 */

#ifndef DICTIONARY_HPP
#define DICTIONARY_HPP

#include <string>
#include <vector>

using namespace std;

/**
 * A Dictionary represents a collection of known English words.  Dictionaries
 * are obviously useful for finding solutions to cryptograms: in this program,
 * Dictionaries are used by Puzzle objects in order to evaluate the quality of
 * possible solution ciphers.  The primary method of a Dictionary is `lookup',
 * which searches a dictionary for a given word.
 */
class Dictionary {
private:
    /**
     * The words in a Dictionary, represented as a vector of strings.
     */
    vector<string> words;
    
public:
    /**
     * Construct a Dictionary from the given array of words.  The end of the
     * array is signaled by a null pointer.  The words in the array are copied
     * into the Dictionary's internal `words' vector.
     *
     * @param the_words    the array of English words
     */
    Dictionary(const char *the_words[]);
    
    /**
     * Destroy a Dictionary object.
     */
    virtual ~Dictionary();
    
    /**
     * Look for a given word in the dictionary.  Return true if the word is in
     * the dictionary, and false if not.  Letter case is ignored in performing
     * the search.  For example, if "this" is in the dictionary, then this
     * method will return true for all of the strings "this", "This", "tHIS",
     * and "THIS".
     *
     * @param word    the string containing the word to be looked up
     * @return        true if the word is the dictionary, false if not
     */
    virtual bool lookup(const string& word) const;
    
private:
    /**
     * Compare two strings to see if they are equal, ignoring any differences
     * in letter case.  For example, "this" and "THIS" would be considered
     * equal.
     *
     * @param s1    the first string to be compared
     * @param s2    the second string to be compared
     * @return      true if the strings are identical modulo case, false if not
     */
    static bool equal_nocase(const string& s1, const string& s2);
};

#endif // DICTIONARY_HPP

// End of file.

