Package com.drew.lang

Class ByteTrie<T>

java.lang.Object
com.drew.lang.ByteTrie<T>
Type Parameters:
T - the type of value to store for byte sequences

public class ByteTrie<T> extends Object
Stores values using a prefix tree (aka 'trie', i.e. reTRIEval data structure).
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    (package private) static class 
    A node in the trie.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private int
     
    private final ByteTrie.ByteTrieNode<T>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addPath(T value, byte[]... parts)
    Store the given value at the specified path.
    find(byte[] bytes)
    Return the most specific value stored for this byte sequence.
    find(byte[] bytes, int offset, int count)
    Return the most specific value stored for this byte sequence.
    int
    Gets the maximum depth stored in this trie.
    void
    setDefaultValue(T defaultValue)
    Sets the default value to use in find(byte[]) when no path matches.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • ByteTrie

      public ByteTrie()
  • Method Details

    • find

      public T find(byte[] bytes)
      Return the most specific value stored for this byte sequence. If not found, returns null or a default values as specified by calling setDefaultValue(T).
    • find

      public T find(byte[] bytes, int offset, int count)
      Return the most specific value stored for this byte sequence. If not found, returns null or a default values as specified by calling setDefaultValue(T).
    • addPath

      public void addPath(T value, byte[]... parts)
      Store the given value at the specified path.
    • setDefaultValue

      public void setDefaultValue(T defaultValue)
      Sets the default value to use in find(byte[]) when no path matches.
    • getMaxDepth

      public int getMaxDepth()
      Gets the maximum depth stored in this trie.