Class Trie

java.lang.Object
  extended byTrie

public class Trie
extends java.lang.Object

An implementation of tries with linked lists


Field Summary
 int size
          number of elements in the trie
 
Constructor Summary
Trie(Alphabet a)
           
 
Method Summary
 void addToTrie(java.lang.String s)
          Adds the word s to the trie.
 void fromFile(java.lang.String name)
           
 boolean isInTrie(java.lang.String s)
           
 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.
static void main(java.lang.String[] args)
           
 void removeFromTrie(java.lang.String s)
          removes the string s from the trie.
 DFA toDFA()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

size

public int size
number of elements in the trie

Constructor Detail

Trie

public Trie(Alphabet a)
Method Detail

longestPrefixInTrie

public 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.

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

isInTrie

public boolean isInTrie(java.lang.String s)

addToTrie

public void addToTrie(java.lang.String s)
Adds the word s to the trie.

Parameters:
s - the string to be added

removeFromTrie

public void removeFromTrie(java.lang.String s)
removes the string s from the trie.

Parameters:
s - the string to be removed

toString

public java.lang.String toString()

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
Throws:
java.io.IOException

fromFile

public void fromFile(java.lang.String name)
              throws java.io.IOException
Throws:
java.io.IOException

toDFA

public DFA toDFA()