Class CharSequenceAnalyzer

  • All Implemented Interfaces:
    java.io.Serializable, java.util.Comparator<java.lang.CharSequence>

    public class CharSequenceAnalyzer
    extends KeyAnalyzer<java.lang.CharSequence>
    See Also:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int bitIndex​(java.lang.CharSequence key, int offsetInBits, int lengthInBits, java.lang.CharSequence other, int otherOffsetInBits, int otherLengthInBits)
      Returns the n-th different bit between key and other.
      int bitsPerElement()
      Returns the number of bits per element in the key.
      int compare​(java.lang.CharSequence o1, java.lang.CharSequence o2)  
      boolean isBitSet​(java.lang.CharSequence key, int bitIndex, int lengthInBits)
      Returns whether or not a bit is set.
      boolean isPrefix​(java.lang.CharSequence prefix, int offsetInBits, int lengthInBits, java.lang.CharSequence key)
      Determines whether or not the given prefix (from offset to length) is a prefix of the given key.
      int lengthInBits​(java.lang.CharSequence key)
      Returns the length of the Key in bits.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Comparator

        equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
    • Field Detail

      • LENGTH

        public static final int LENGTH
        The number of bits per Character.
        See Also:
        Constant Field Values
    • Constructor Detail

      • CharSequenceAnalyzer

        public CharSequenceAnalyzer()
    • Method Detail

      • bitsPerElement

        public int bitsPerElement()
        Description copied from class: KeyAnalyzer
        Returns the number of bits per element in the key. This is only useful for variable-length keys, such as Strings.
        Specified by:
        bitsPerElement in class KeyAnalyzer<java.lang.CharSequence>
        Returns:
        the number of bits per element
      • lengthInBits

        public int lengthInBits​(java.lang.CharSequence key)
        Description copied from class: KeyAnalyzer
        Returns the length of the Key in bits.
        Specified by:
        lengthInBits in class KeyAnalyzer<java.lang.CharSequence>
        Parameters:
        key - the key
        Returns:
        the bit length of the key
      • bitIndex

        public int bitIndex​(java.lang.CharSequence key,
                            int offsetInBits,
                            int lengthInBits,
                            java.lang.CharSequence other,
                            int otherOffsetInBits,
                            int otherLengthInBits)
        Description copied from class: KeyAnalyzer
        Returns the n-th different bit between key and other. This starts the comparison in key at 'offsetInBits' and goes for 'lengthInBits' bits, and compares to the other key starting at 'otherOffsetInBits' and going for 'otherLengthInBits' bits.
        Specified by:
        bitIndex in class KeyAnalyzer<java.lang.CharSequence>
        Parameters:
        key - the key to use
        offsetInBits - the bit offset in the key
        lengthInBits - the maximum key length in bits to use
        other - the other key to use
        otherOffsetInBits - the bit offset in the other key
        otherLengthInBits - the maximum key length in bits for the other key
        Returns:
        the bit index where the key and other first differ
      • isBitSet

        public boolean isBitSet​(java.lang.CharSequence key,
                                int bitIndex,
                                int lengthInBits)
        Description copied from class: KeyAnalyzer
        Returns whether or not a bit is set.
        Specified by:
        isBitSet in class KeyAnalyzer<java.lang.CharSequence>
        Parameters:
        key - the key to check, may not be null
        bitIndex - the bit index to check
        lengthInBits - the maximum key length in bits to check
        Returns:
        true if the bit is set in the given key and bitIndex < lengthInBits, false otherwise.
      • isPrefix

        public boolean isPrefix​(java.lang.CharSequence prefix,
                                int offsetInBits,
                                int lengthInBits,
                                java.lang.CharSequence key)
        Description copied from class: KeyAnalyzer
        Determines whether or not the given prefix (from offset to length) is a prefix of the given key.
        Specified by:
        isPrefix in class KeyAnalyzer<java.lang.CharSequence>
        Parameters:
        prefix - the prefix to check
        offsetInBits - the bit offset in the key
        lengthInBits - the maximum key length in bits to use
        key - the key to check
        Returns:
        true if this is a valid prefix for the given key
      • compare

        public int compare​(java.lang.CharSequence o1,
                           java.lang.CharSequence o2)
        Specified by:
        compare in interface java.util.Comparator<java.lang.CharSequence>
        Overrides:
        compare in class KeyAnalyzer<java.lang.CharSequence>