Пример #1
0
  /**
   * Creates a Trie object for a SimpleDictionary with all words reversed
   *
   * @param aDict a dictionary.
   * @return the resulting trie.
   */
  public static TrieStructure createForDictReverse(Dictionary aDict) {
    TrieStructure t = new TrieStructure();

    for (String word : aDict.getAll()) {
      t.addWord(new StringBuffer(word).reverse().toString());
    }

    return t;
  }
Пример #2
0
  /**
   * Creates a Trie object for a SimpleDictionary
   *
   * @param aDict a dictionary.
   * @return the resulting trie.
   */
  public static TrieStructure createForDict(Dictionary aDict) {
    TrieStructure t = new TrieStructure();

    for (String word : aDict.getAll()) {
      t.addWord(word);
    }

    return t;
  }