Class CharTrieOfFew

  • All Implemented Interfaces:
    CharTrie

    final class CharTrieOfFew
    extends java.lang.Object
    implements CharTrie
    A trie for testing if a String is contained in a set of Strings.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private CharTrieNode root  
    • Constructor Summary

      Constructors 
      Constructor Description
      CharTrieOfFew​(java.util.Set<java.lang.String> set)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void add​(java.lang.String str)  
      int match​(char[] str, int startIndex, int endIndex)
      Searches for the longest matching string in the trie that matches the provided string.
      int match​(java.lang.CharSequence str, int startIndex, int endIndex)
      Searches for the longest matching string in the trie that matches the provided string.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CharTrieOfFew

        public CharTrieOfFew​(java.util.Set<java.lang.String> set)
    • Method Detail

      • add

        private void add​(java.lang.String str)
      • match

        public int match​(java.lang.CharSequence str,
                         int startIndex,
                         int endIndex)
        Description copied from interface: CharTrie
        Searches for the longest matching string in the trie that matches the provided string.
        Specified by:
        match in interface CharTrie
        Parameters:
        str - a string
        startIndex - start index (inclusive)
        endIndex - end index (exclusive)
        Returns:
        the length of the longest matching string, or 0 if no string matches
      • match

        public int match​(char[] str,
                         int startIndex,
                         int endIndex)
        Description copied from interface: CharTrie
        Searches for the longest matching string in the trie that matches the provided string.
        Specified by:
        match in interface CharTrie
        Parameters:
        str - a string
        startIndex - start index (inclusive)
        endIndex - end index (exclusive)
        Returns:
        the length of the longest matching string, or 0 if no string matches