feisty meow concerns codebase  2.140
SimpleDictionary.java
Go to the documentation of this file.
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 
11  private static final long serialVersionUID = 1L;
12 
13  public SimpleDictionary(Set<String> words)
14  {
15  addAll(words);
17  }
18 
19  public SimpleDictionary(String words[])
20  {
21  for (String word : words) {
22  add(word);
23  }
25  }
26 
27  public int computeLongestWord()
28  {
29  previouslyComputedLongestWord = 1;
30 
31  // hmmm: iterate on set to find longest.
32 
33  // kludge implem placeholder.
34  previouslyComputedLongestWord = 100;
35  return previouslyComputedLongestWord;
36  }
37 
38  public boolean lookup(String toFind)
39  {
40  return contains(toFind);
41  }
42 
43  public int longestWord()
44  {
45  return previouslyComputedLongestWord;
46  }
47 
48  int previouslyComputedLongestWord;
49 }