org.h2.util
Class BitField

java.lang.Object
  extended by org.h2.util.BitField

public class BitField
extends java.lang.Object

A list of bits.


Constructor Summary
BitField()
           
 
Method Summary
 void clear(int i)
          Set bit at the given index to 'false'.
 boolean get(int i)
          Get the bit at the given index.
 int getByte(int i)
          Get the next 8 bits at the given index.
 int getLastSetBit()
          Get the index of the last bit that is set.
 long getLong(int i)
          Get the bit mask of the bits at the given index.
 int nextClearBit(int fromIndex)
          Get the index of the next bit that is not set.
 int nextSetBit(int fromIndex)
          Get the index of the next bit that is set.
 void set(int i)
          Set bit at the given index to 'true'.
 void setByte(int i, int x)
          Combine the next 8 bits at the given index with OR.
 void setRange(int start, int len, boolean value)
          Enable or disable a number of bits.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitField

public BitField()
Method Detail

getLastSetBit

public int getLastSetBit()
Get the index of the last bit that is set.

Returns:
the index of the last enabled bit, or -1

nextSetBit

public int nextSetBit(int fromIndex)
Get the index of the next bit that is set.

Parameters:
fromIndex - where to start searching
Returns:
the index of the next enabled bit

nextClearBit

public int nextClearBit(int fromIndex)
Get the index of the next bit that is not set.

Parameters:
fromIndex - where to start searching
Returns:
the index of the next disabled bit

getLong

public long getLong(int i)
Get the bit mask of the bits at the given index.

Parameters:
i - the index (must be a multiple of 64)
Returns:
the bit mask as a long

get

public boolean get(int i)
Get the bit at the given index.

Parameters:
i - the index
Returns:
true if the bit is enabled

getByte

public int getByte(int i)
Get the next 8 bits at the given index. The index must be a multiple of 8.

Parameters:
i - the index
Returns:
the next 8 bits

setByte

public void setByte(int i,
                    int x)
Combine the next 8 bits at the given index with OR. The index must be a multiple of 8.

Parameters:
i - the index
x - the next 8 bits (0 - 255)

set

public void set(int i)
Set bit at the given index to 'true'.

Parameters:
i - the index

clear

public void clear(int i)
Set bit at the given index to 'false'.

Parameters:
i - the index

setRange

public void setRange(int start,
                     int len,
                     boolean value)
Enable or disable a number of bits.

Parameters:
start - the index of the first bit to enable or disable
len - the number of bits to enable or disable
value - the new value