org.archive.wayback.util
Class BitArray

java.lang.Object
  extended by org.archive.wayback.util.BitArray

public class BitArray
extends Object

Author:
brad

Constructor Summary
BitArray(byte[] array)
          Construct a new BitArray using argument as initial values.
BitArray(ByteBuffer bb)
          Construct a new BitArray holding at least n bits
BitArray(int n)
          Construct a new BitArray holding at least n bits
 
Method Summary
 boolean get(int i)
           
 ByteBuffer getByteBuffer()
           
 byte[] getBytes()
           
 void set(int i, boolean value)
          set the i'th bit to 1 or 0
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitArray

public BitArray(int n)
Construct a new BitArray holding at least n bits

Parameters:
n - number of bits to hold

BitArray

public BitArray(byte[] array)
Construct a new BitArray using argument as initial values.

Parameters:
array - byte array of initial values

BitArray

public BitArray(ByteBuffer bb)
Construct a new BitArray holding at least n bits

Parameters:
bb - number of bits to hold
Method Detail

getBytes

public byte[] getBytes()
Returns:
the byte array backing the ByteBuffer backing this bit array.

getByteBuffer

public ByteBuffer getByteBuffer()
Returns:
the ByteBuffer backing this bit array.

get

public boolean get(int i)
Parameters:
i - index of bit to test
Returns:
true if the i'th bit is set, false otherwise

set

public void set(int i,
                boolean value)
set the i'th bit to 1 or 0

Parameters:
i - bit number to set
value - if true, the bit is set to 1, otherwise it is set to 0


Copyright © 2005-2011 Internet Archive. All Rights Reserved.