X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=kona%2Fsrc%2Forg%2Ffeistymeow%2Ftextual%2FSimpleDictionary.java;fp=kona%2Fsrc%2Forg%2Ffeistymeow%2Ftextual%2FSimpleDictionary.java;h=9008ac97246456d40fe852aa4b9e4b76cdca4d04;hb=7b39f7e279005c8466ef508220a532ce2aa4abf8;hp=0000000000000000000000000000000000000000;hpb=3fbd372b35b15a19fb171d5ae34294ff7b1e6485;p=feisty_meow.git diff --git a/kona/src/org/feistymeow/textual/SimpleDictionary.java b/kona/src/org/feistymeow/textual/SimpleDictionary.java new file mode 100644 index 00000000..9008ac97 --- /dev/null +++ b/kona/src/org/feistymeow/textual/SimpleDictionary.java @@ -0,0 +1,49 @@ +package org.feistymeow.textual; + +import java.util.HashSet; +import java.util.Set; + +public class SimpleDictionary extends HashSet +// or alternatively, BinaryTree +// => what is BST implem for java! is it balanced? +{ + + private static final long serialVersionUID = 1L; + + public SimpleDictionary(Set words) + { + addAll(words); + computeLongestWord(); + } + + public SimpleDictionary(String words[]) + { + for (String word : words) { + add(word); + } + computeLongestWord(); + } + + public int computeLongestWord() + { + previouslyComputedLongestWord = 1; + + // hmmm: iterate on set to find longest. + + // kludge implem placeholder. + previouslyComputedLongestWord = 100; + return previouslyComputedLongestWord; + } + + public boolean lookup(String toFind) + { + return contains(toFind); + } + + public int longestWord() + { + return previouslyComputedLongestWord; + } + + int previouslyComputedLongestWord; +}