edu.northwestern.at.utils
Class XBitSet

java.lang.Object
  extended by java.util.BitSet
      extended by edu.northwestern.at.utils.XBitSet
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class XBitSet
extends java.util.BitSet

An enhanced bitset.

See Also:
Serialized Form

Field Summary
static XBitSet EMPTY_SET
          The empty set.
 
Constructor Summary
XBitSet()
          Constructs a new empty bitset.
XBitSet(int nbits)
          Constructs a new empty bitset with enough room for nbits bits.
XBitSet(int[] bits)
          Constructs a new bitset from an array.
XBitSet(int nbits, int[] bits)
          Constructs a new bitset with enough room for nbits bits from an array.
 
Method Summary
 int count()
          Gets the number of elements in the bitset.
 IntIterator iterator()
          Gets an iterator over the bitset.
 XBitSet or(XBitSet bitSet)
          Or another XBitSet with this one.
 void set(int bitIndex, boolean value)
          Sets the bit at a specificed index to a specified value.
 
Methods inherited from class java.util.BitSet
and, andNot, cardinality, clear, clear, clear, clone, equals, flip, flip, get, get, hashCode, intersects, isEmpty, length, nextClearBit, nextSetBit, or, set, set, set, size, toString, xor
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY_SET

public static final XBitSet EMPTY_SET
The empty set.

Constructor Detail

XBitSet

public XBitSet()
Constructs a new empty bitset.


XBitSet

public XBitSet(int nbits)
Constructs a new empty bitset with enough room for nbits bits.

Parameters:
nbits - The initial size of the bitset.

XBitSet

public XBitSet(int[] bits)
Constructs a new bitset from an array.

Parameters:
bits - An array of the initial bits to set.

XBitSet

public XBitSet(int nbits,
               int[] bits)
Constructs a new bitset with enough room for nbits bits from an array.

Parameters:
nbits - The initial size of the bitset.
bits - An array of the initial bits to set.
Method Detail

count

public int count()
Gets the number of elements in the bitset.

Returns:
The number of elements.

iterator

public IntIterator iterator()
Gets an iterator over the bitset.

The behavior of the iterator is unspecified if the underlying bitset is modified while the iteration is in progress.

Returns:
The iterator.

or

public XBitSet or(XBitSet bitSet)
Or another XBitSet with this one.

Returns:
This bitset ORed with the specified bitset.

set

public void set(int bitIndex,
                boolean value)
Sets the bit at a specificed index to a specified value.

Overrides:
set in class java.util.BitSet
Parameters:
bitIndex - Bit index.
value - The boolean value to set.