Class StringUnionOperations


  • public final class StringUnionOperations
    extends java.lang.Object
    Operations for building minimal deterministic automata from sets of strings. The algorithm requires sorted input data, but is very fast (nearly linear with the input size).
    • Constructor Detail

      • StringUnionOperations

        public StringUnionOperations()
    • Method Detail

      • add

        public void add​(java.lang.CharSequence current)
        Add another character sequence to this automaton. The sequence must be lexicographically larger or equal compared to any previous sequences added to this automaton (the input must be sorted).
      • complete

        public StringUnionOperations.State complete()
        Finalize the automaton and return the root state. No more strings can be added to the builder after this call.
        Returns:
        Root automaton state.
      • build

        public static State build​(java.lang.CharSequence[] input)
        Build a minimal, deterministic automaton from a sorted list of strings.
      • setPrevious

        private boolean setPrevious​(java.lang.CharSequence current)
        Copy current into an internal buffer.
      • replaceOrRegister

        private void replaceOrRegister​(StringUnionOperations.State state)
        Replace last child of state with an already registered state or register the last child state.
      • addSuffix

        private void addSuffix​(StringUnionOperations.State state,
                               java.lang.CharSequence current,
                               int fromIndex)
        Add a suffix of current starting at fromIndex (inclusive) to state state.