org.neo4j.kernel.impl.util
Class Bits

java.lang.Object
  extended by org.neo4j.kernel.impl.util.Bits

public class Bits
extends Object

Got bits to store, shift and retrieve and they are more than what fits in a long? Use Bits then.


Method Summary
 Bits apply(Buffer buffer)
          Writes all bits to buffer.
 byte[] asBytes()
           
 boolean available()
           
static Bits bits(int numberOfBytes)
           
static Bits bitsFromBytes(byte[] bytes)
           
static Bits bitsFromBytes(byte[] bytes, int startIndex)
           
static Bits bitsFromLongs(long[] longs)
           
 Bits clone()
           
 byte getByte()
           
 byte getByte(int steps)
           
 int getInt()
           
 int getInt(int steps)
           
 long getLong()
           
 long getLong(int steps)
           
 long[] getLongs()
          Returns the underlying long values that has got all the bits applied.
 short getShort()
           
 short getShort(int steps)
           
 long getUnsignedInt()
           
static long leftOverflowMask(int steps)
          A mask which has the steps most significant bits set to 1, all others 0.
static String numbersToBitString(byte[] values)
           
static String numbersToBitString(int[] values)
           
static String numbersToBitString(long[] values)
           
static String numbersToBitString(short[] values)
           
static StringBuilder numberToString(StringBuilder builder, long value, int numberOfBytes)
           
 Bits put(byte value)
           
 Bits put(byte value, int steps)
           
 Bits put(int value)
           
 Bits put(int value, int steps)
           
 Bits put(long value)
           
 Bits put(long value, int steps)
           
 Bits put(short value)
           
 Bits put(short value, int steps)
           
 Bits read(Buffer buffer)
          Reads from buffer and fills up all the bits.
static long rightOverflowMask(int steps)
          A mask which has the steps least significant bits set to 1, all others 0.
 String toString()
          A very nice toString, showing each bit, divided into groups of bytes and lines of 8 bytes.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

bits

public static Bits bits(int numberOfBytes)

bitsFromLongs

public static Bits bitsFromLongs(long[] longs)

bitsFromBytes

public static Bits bitsFromBytes(byte[] bytes)

bitsFromBytes

public static Bits bitsFromBytes(byte[] bytes,
                                 int startIndex)

leftOverflowMask

public static long leftOverflowMask(int steps)
A mask which has the steps most significant bits set to 1, all others 0. It's used to carry bits over between carriers (longs) when shifting left.

Parameters:
steps - the number of most significant bits to have set to 1 in the mask.
Returns:
the created mask.

rightOverflowMask

public static long rightOverflowMask(int steps)
A mask which has the steps least significant bits set to 1, all others 0. It's used to carry bits over between carriers (longs) when shifting right.

Parameters:
steps - the number of least significant bits to have set to 1 in the mask.
Returns:
the created mask.

getLongs

public long[] getLongs()
Returns the underlying long values that has got all the bits applied. The first item in the array has got the most significant bits.

Returns:
the underlying long values that has got all the bits applied.

asBytes

public byte[] asBytes()

apply

public Bits apply(Buffer buffer)
Writes all bits to buffer.

Parameters:
buffer - the Buffer to write to.
Returns:
this instance.

read

public Bits read(Buffer buffer)
Reads from buffer and fills up all the bits.

Parameters:
buffer - the Buffer to read from.
Returns:
this instance.

toString

public String toString()
A very nice toString, showing each bit, divided into groups of bytes and lines of 8 bytes.

Overrides:
toString in class Object

numberToString

public static StringBuilder numberToString(StringBuilder builder,
                                           long value,
                                           int numberOfBytes)

numbersToBitString

public static String numbersToBitString(byte[] values)

numbersToBitString

public static String numbersToBitString(short[] values)

numbersToBitString

public static String numbersToBitString(int[] values)

numbersToBitString

public static String numbersToBitString(long[] values)

clone

public Bits clone()
Overrides:
clone in class Object

put

public Bits put(byte value)

put

public Bits put(byte value,
                int steps)

put

public Bits put(short value)

put

public Bits put(short value,
                int steps)

put

public Bits put(int value)

put

public Bits put(int value,
                int steps)

put

public Bits put(long value)

put

public Bits put(long value,
                int steps)

available

public boolean available()

getByte

public byte getByte()

getByte

public byte getByte(int steps)

getShort

public short getShort()

getShort

public short getShort(int steps)

getInt

public int getInt()

getInt

public int getInt(int steps)

getUnsignedInt

public long getUnsignedInt()

getLong

public long getLong()

getLong

public long getLong(int steps)


Copyright © 2002-2012 The Neo4j Graph Database Project. All Rights Reserved.