Class ByteTrieOfFewIgnoreCase

  • All Implemented Interfaces:
    ByteTrie

    final class ByteTrieOfFewIgnoreCase
    extends java.lang.Object
    implements ByteTrie
    A trie for testing if a String is contained in a set of Strings.

    This trie is a directed acyclic graph. The trie contains UTF-8 encoded characters.

         Given: the strings: "NaN" in latin alphabet,
                             "інф" in cyrillic alphabet.
    
         The latin alphabet is encoded with one byte per character.
         The cyrillic alphabet is encoded with 2 bytes per character.
    
         "NAN" upper case bytes:  { 0x4e, 0x41, 0x4e }
         "nan" lower case bytes:  { 0x6e, 0x61, 0x6e }
         "ІНФ" upper case bytes:  { 0xd0, 0x86, 0xd0, 0x9d, 0xd0, 0xa4 }
         "інф" lower case bytes:  { 0xd1, 0x96, 0xd0, 0xbd, 0xd1, 0x84 }
    
         The trie will have the following structure:
    
         root [0xd0,    0xd1, 'N'0x4e,'n'0x6e]
        ┌───────┘        │        └─────┬─┘
        ↓                │              ↓
      node ['І'0x86]     ↓            node ['A'0x41,'a'0x61]
                │      node ['і'0x96]            └───┬───┘
                └─┬─────────────┘                   ↓
                  ↓                               node ['N'0x4e,'n'0x6e]
                node [0xd0]
         ┌────────────┴─┐
         ↓              ↓
      node ['Н'0x9d]   node ['н'0xbd]
                └─┬─────────────┘
                  ↓
                node [0xd0, 0xd1]
        ┌──────────────┘ ┌───┘
        ↓                ↓
      node ['Ф'0xa4]   node ['ф'0x84]
     
    • Field Summary

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

      Constructors 
      Constructor Description
      ByteTrieOfFewIgnoreCase​(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​(byte[] 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
      • Methods inherited from interface ch.randelshofer.fastdoubleparser.bte.ByteTrie

        match
    • Constructor Detail

      • ByteTrieOfFewIgnoreCase

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

      • add

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

        public int match​(byte[] str,
                         int startIndex,
                         int endIndex)
        Description copied from interface: ByteTrie
        Searches for the longest matching string in the trie that matches the provided string.
        Specified by:
        match in interface ByteTrie
        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