org.ardverk.collection
Class ByteArrayKeyAnalyzer

java.lang.Object
  extended by org.ardverk.collection.AbstractKeyAnalyzer<byte[]>
      extended by org.ardverk.collection.ByteArrayKeyAnalyzer
All Implemented Interfaces:
java.io.Serializable, java.util.Comparator<byte[]>, KeyAnalyzer<byte[]>

public class ByteArrayKeyAnalyzer
extends AbstractKeyAnalyzer<byte[]>

A KeyAnalyzer for byte[]s

See Also:
Serialized Form

Field Summary
static ByteArrayKeyAnalyzer INSTANCE
          A singleton instance of ByteArrayKeyAnalyzer
static int LENGTH
          The length of an Byte in bits
 
Fields inherited from interface org.ardverk.collection.KeyAnalyzer
EQUAL_BIT_KEY, NULL_BIT_KEY, OUT_OF_BOUNDS_BIT_KEY
 
Constructor Summary
ByteArrayKeyAnalyzer(int maxLengthInBits)
           
 
Method Summary
 int bitIndex(byte[] key, int offsetInBits, int lengthInBits, byte[] other, int otherOffsetInBits, int otherLengthInBits)
          Returns the n-th different bit between key and found.
 int bitsPerElement()
          Returns the number of bits per element in the key.
 int compare(byte[] o1, byte[] o2)
          
 int getMaxLengthInBits()
          Returns the maximum length of a key in bits
 boolean isBitSet(byte[] key, int bitIndex, int lengthInBits)
          Returns whether or not a bit is set
 boolean isPrefix(byte[] prefix, int offsetInBits, int lengthInBits, byte[] key)
          Determines whether or not the given prefix (from offset to length) is a prefix of the given key.
 int lengthInBits(byte[] 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
 

Field Detail

INSTANCE

public static final ByteArrayKeyAnalyzer INSTANCE
A singleton instance of ByteArrayKeyAnalyzer


LENGTH

public static final int LENGTH
The length of an Byte in bits

See Also:
Constant Field Values
Constructor Detail

ByteArrayKeyAnalyzer

public ByteArrayKeyAnalyzer(int maxLengthInBits)
Method Detail

getMaxLengthInBits

public int getMaxLengthInBits()
Returns the maximum length of a key in bits


bitsPerElement

public int bitsPerElement()
Returns the number of bits per element in the key. This is only useful for variable-length keys, such as Strings.


lengthInBits

public int lengthInBits(byte[] key)
Returns the length of the Key in bits.


isBitSet

public boolean isBitSet(byte[] key,
                        int bitIndex,
                        int lengthInBits)
Returns whether or not a bit is set


bitIndex

public int bitIndex(byte[] key,
                    int offsetInBits,
                    int lengthInBits,
                    byte[] other,
                    int otherOffsetInBits,
                    int otherLengthInBits)
Returns the n-th different bit between key and found. This starts the comparison in key at 'keyStart' and goes for 'keyLength' bits, and compares to the found key starting at 'foundStart' and going for 'foundLength' bits.


isPrefix

public boolean isPrefix(byte[] prefix,
                        int offsetInBits,
                        int lengthInBits,
                        byte[] key)
Determines whether or not the given prefix (from offset to length) is a prefix of the given key.


compare

public int compare(byte[] o1,
                   byte[] o2)

Specified by:
compare in interface java.util.Comparator<byte[]>
Overrides:
compare in class AbstractKeyAnalyzer<byte[]>


Copyright © 2005-2009 Roger Kapsi, Sam Berlin. All Rights Reserved.