6d71f9b83c16e202b6b5486e562f43f51e4495c9
[feisty_meow.git] / kona / src / org / feistymeow / textual / SimpleDictionary.java
1 package org.feistymeow.textual;
2
3 import java.util.HashSet;
4 import java.util.Set;
5
6 public class SimpleDictionary extends HashSet<String>
7 //or alternatively, BinaryTree<String>
8 //=> what is BST implem for java!  is it balanced?
9 {
10   public SimpleDictionary (Set<String> words) {
11     addAll(words);
12     computeLongestWord();
13   }
14   
15   public SimpleDictionary (String words[]) {
16         for (String word : words) {
17                 add(word);
18         }
19     computeLongestWord();
20   }
21
22   public int computeLongestWord() {
23     previouslyComputedLongestWord = 1;
24     
25     //hmmm: iterate on set to find longest.
26     
27 //kludge implem placeholder.
28 previouslyComputedLongestWord = 100;
29         return previouslyComputedLongestWord;
30   }
31   
32   public boolean lookup(String toFind) {
33     return contains(toFind);
34   }
35
36   public int longestWord() {
37     return previouslyComputedLongestWord;
38   }
39
40   int previouslyComputedLongestWord;
41 }
42