Class ByteTrieOfFewIgnoreCase

java.lang.Object
ch.randelshofer.fastdoubleparser.bte.ByteTrieOfFewIgnoreCase
All Implemented Interfaces:
ByteTrie

final class ByteTrieOfFewIgnoreCase extends 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 Details

  • Constructor Details

    • ByteTrieOfFewIgnoreCase

      public ByteTrieOfFewIgnoreCase(Set<String> set)
  • Method Details

    • add

      private void add(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