Interface Trie

All Known Implementing Classes:
FixedArrayTrie, ForaxTrie, VariableArrayTrie

public interface Trie

Interface for the implementation of the Trie data structure.


Method Summary
 void addToTrie(java.lang.String s)
          Adds the word s to the trie.
 void fromFile(java.lang.String name)
          Builds a trie representing the list of strings read from a file line by line.
 boolean isInTrie(java.lang.String s)
          Returns true if the trie contains s.
 boolean isLeaf()
          Returns true if the node p is a leaf of the trie.
 Pair longestPrefixInTrie(java.lang.String s, int j)
          Computes the pair composed of the length of the longest prefix of s[j..n-1] in the trie and the vertex reached by this prefix.
 void removeFromTrie(java.lang.String s)
          removes the string s from the trie.
 

Method Detail

longestPrefixInTrie

public Pair longestPrefixInTrie(java.lang.String s,
                                int j)
Computes the pair composed of the length of the longest prefix of s[j..n-1] in the trie and the vertex reached by this prefix. Implements the function LongestPrefixInTrie() of Section 1.3.1.

Parameters:
s - the input string
j - the starting index
Returns:
the computed pair

isInTrie

public boolean isInTrie(java.lang.String s)
Returns true if the trie contains s. Implements the function IsInTrie() of Section 1.3.1.


addToTrie

public void addToTrie(java.lang.String s)
Adds the word s to the trie. Implements the function AddToTrie() of Section 1.3.1.

Parameters:
s - the string to be added.

isLeaf

public boolean isLeaf()
Returns true if the node p is a leaf of the trie. Implements the function IsLeaf() of Section 1.3.1.


removeFromTrie

public void removeFromTrie(java.lang.String s)
removes the string s from the trie. Implements the function RemoveFromTrie() of Section 1.3.1.

Parameters:
s - the string to be removed

fromFile

public void fromFile(java.lang.String name)
              throws java.io.IOException
Builds a trie representing the list of strings read from a file line by line.

Parameters:
name - the name of the file
Throws:
java.io.IOException