Class WordListDictionary

  • All Implemented Interfaces:

    public class WordListDictionary
    extends Object
    implements Dictionary
    Provides fast searching for dictionary words using a word list. It's critical that the word list provided to this dictionary be sorted according to the natural ordering of String.
    Middleware Services
    • Field Detail

      • wordList

        protected final WordList wordList
        list used for searching.
    • Constructor Detail

      • WordListDictionary

        public WordListDictionary​(WordList wl)
        Creates a new dictionary instance from the supplied WordList.
        wl - list of words sorted according to WordList.getComparator().

        NOTE Failure to provide a sorted word list will produce incorrect results.

    • Method Detail

      • getWordList

        public WordList getWordList()
        Returns the word list used for searching.
        word list
      • size

        public long size()
        Description copied from interface: Dictionary
        Returns the number of words in this dictionary
        Specified by:
        size in interface Dictionary
        total number of words to search
      • search

        public boolean search​(String word)
        Description copied from interface: Dictionary
        Returns whether the supplied word exists in the dictionary.
        Specified by:
        search in interface Dictionary
        word - to search for
        whether word was found
      • main

        public static void main​(String[] args)
                         throws Exception
        Provides command line access to this word list dictionary.
        args - command line arguments
        Exception - if an error occurs