org.ka2ddo.util
Class HugeBitSet

java.lang.Object
  extended by org.ka2ddo.util.HugeBitSet

public final class HugeBitSet
extends java.lang.Object

This class implements a BitSet using a segmented array, so that growth to unreasonably huge sizes will not require having enough heap space for two contiguous copies of the bitset (to handle copying upon array growth). Instead, this class adds more segments, so existing segment data does not have to be copied and the size of contiguous heap allocations remains constant instead of growing.

Note that the maximum size of a HugeBitSet is 2**32 - 1 bits.


Constructor Summary
HugeBitSet()
           
 
Method Summary
 void clear()
          Clear all the bits in the HugeBitSet.
 boolean clear(int index)
          Clear the specified bit in the HugeBitSet.
 boolean get(int index)
          Test if the specified bit is set in the HugeBitSet.
 boolean isSet(int index)
          Test if the specified bit is set in the HugeBitSet.
 void justSet(int index)
          Set the specified bit in the HugeBitSet without returning the former state.
 int length()
          Get the maximum number of bits currently allocated in this HugeBitSet.
 boolean set(int index)
          Set the specified bit in the HugeBitSet.
 java.lang.String toString()
          Generate a String describing this HugeBitSet.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HugeBitSet

public HugeBitSet()
Method Detail

set

public boolean set(int index)
Set the specified bit in the HugeBitSet.

Parameters:
index - zero-based int index of the bit to set
Returns:
boolean true if the bit was set prior to this call, false if clear

justSet

public void justSet(int index)
Set the specified bit in the HugeBitSet without returning the former state.

Parameters:
index - zero-based int index of the bit to set

clear

public boolean clear(int index)
Clear the specified bit in the HugeBitSet.

Parameters:
index - zero-based int index of the bit to set
Returns:
boolean true if the bit was set prior to this call, false if clear

clear

public void clear()
Clear all the bits in the HugeBitSet. Note that this does not free any storage blocks allocated by previous calls to set() or justSet().


get

public boolean get(int index)
Test if the specified bit is set in the HugeBitSet.

Parameters:
index - zero-based index of bit to test
Returns:
boolean true if bit is set, or false if bit is clear

isSet

public boolean isSet(int index)
Test if the specified bit is set in the HugeBitSet.

Parameters:
index - zero-based index of bit to test
Returns:
boolean true if bit is set, or false if bit is clear

toString

public java.lang.String toString()
Generate a String describing this HugeBitSet.

Overrides:
toString in class java.lang.Object
Returns:
descriptive String

length

public int length()
Get the maximum number of bits currently allocated in this HugeBitSet.

Returns:
maximum bit index + 1 currently allocated