Class PrefixMap<P>


  • @Immutable
    public final class PrefixMap<P>
    extends java.lang.Object
    Provides a map from prefix to arbitrary element, allowing to iterate over all elements whose prefixes matches a given byte[].

    To create a PrefixMap, the user adds pairs (Prefix, Value), as in a map. To query, the user provides a byte[] and the map will allow to iterate over all values which were added with a prefix of the given byte[].

    Currently only supports prefixes of length 5 and 0.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  PrefixMap.Builder<P>
      Builder for PrefixMap.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Iterable<P> getAllWithMatchingPrefix​(byte[] text)
      Provides an iterable which goves over all values which were added with a prefix of the given text.
      • Methods inherited from class java.lang.Object

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

      • getAllWithMatchingPrefix

        public java.lang.Iterable<P> getAllWithMatchingPrefix​(byte[] text)
        Provides an iterable which goves over all values which were added with a prefix of the given text.

        The matches with the longest prefixes are returned first. Within a given length, the values are returned in the order they were provided in the builder.