Class SuffixTrees


  • public class SuffixTrees
    extends java.lang.Object
    Utilities for working with suffix trees.
    Author:
    Garret Wilson
    • Constructor Detail

      • SuffixTrees

        public SuffixTrees()
    • Method Detail

      • print

        public static void print​(SuffixTree suffixTree,
                                 java.io.PrintStream printStream)
        Prints a character representation of the tree and its branches, starting from the root node.
        Parameters:
        suffixTree - The suffix tree to print.
        printStream - The destination to which the tree should be printed.
        Throws:
        java.lang.NullPointerException - if the given suffix tree and/or print stream is null.
      • print

        protected static void print​(SuffixTree suffixTree,
                                    java.io.PrintStream printStream,
                                    SuffixTree.Node node,
                                    int level)
        Prints a character representation of the given node.
        Parameters:
        suffixTree - The suffix tree to print.
        printStream - The destination to which the tree should be printed.
        node - The node the child edges to print.
        level - The zero-based level of the tree from the root.
        Throws:
        java.lang.NullPointerException - if the given suffix tree, print stream, and/or node is null.
      • print

        protected static void print​(SuffixTree suffixTree,
                                    java.io.PrintStream printStream,
                                    SuffixTree.Edge edge,
                                    int level)
        Prints a character representation of the child edges of the given edge.
        Parameters:
        suffixTree - The suffix tree to print.
        printStream - The destination to which the tree should be printed.
        edge - The edge the child edges of which to print.
        level - The zero-based level of the tree from the root.
        Throws:
        java.lang.NullPointerException - if the given suffix tree and/or print stream and/or edge is null.
      • visit

        public static <N extends SuffixTree.Node,​E extends SuffixTree.Edge> boolean visit​(SuffixTree suffixTree,
                                                                                                SuffixTrees.Visitor<N,​E> visitor)
        Recursively visits all the nodes in a given suffix tree.
        Type Parameters:
        N - The type of node.
        E - The type of edge.
        Parameters:
        suffixTree - The suffix tree to visit.
        visitor - The visitor to visit the nodes of the suffix tree.
        Returns:
        true if visiting completed all the nodes.
        Throws:
        java.lang.NullPointerException - if the given suffix tree and/or visitor is null.
      • visit

        public static <N extends SuffixTree.Node,​E extends SuffixTree.Edge> boolean visit​(SuffixTree suffixTree,
                                                                                                N node,
                                                                                                E parentEdge,
                                                                                                int length,
                                                                                                SuffixTrees.Visitor<N,​E> visitor)
        Recursively visits a given node and all descendant nodes in a subtree of a suffix tree.
        Type Parameters:
        N - The type of node.
        E - The type of edge.
        Parameters:
        suffixTree - The suffix tree to visit.
        node - The node being visited.
        parentEdge - The parent edge of the node being visited, or null if the node has no parent.
        length - The length of elements up to the visited node, including the length of the parent edge.
        visitor - The visitor to visit the nodes of the suffix tree.
        Returns:
        true if visiting completed all the nodes.
      • visitChildren

        public static <N extends SuffixTree.Node,​E extends SuffixTree.Edge> boolean visitChildren​(SuffixTree suffixTree,
                                                                                                        N node,
                                                                                                        int length,
                                                                                                        SuffixTrees.Visitor<N,​E> visitor)
        Recursively visits all descendant nodes in a subtree of a suffix tree.
        Type Parameters:
        N - The type of node.
        E - The type of edge.
        Parameters:
        suffixTree - The suffix tree to visit.
        node - The node being visited.
        length - The length of elements up to the visited node, including the length of the parent edge.
        visitor - The visitor to visit the nodes of the suffix tree.
        Returns:
        true if visiting completed all the nodes.