Methods Summary |
---|
public com.sun.org.apache.xalan.internal.xsltc.dom.BitArray | cloneArray()
return(new BitArray(_intSize, _bits));
|
public final int[] | data()Returns the integer array in which the bit array is contained
return(_bits);
|
public final boolean | getBit(int bit)Returns true if the given bit is set
if (DEBUG_ASSERTIONS) {
if (bit >= _bitSize) {
throw new Error(
"Programmer's assertion in BitArray.getBit");
}
}
return((_bits[bit>>>5] & _masks[bit%32]) != 0);
|
public final int | getBitNumber(int pos)
// Return last node if position we're looking for is the same
if (pos == _pos) return(_node);
// Start from beginning of position we're looking for is before
// the point where we left off the last time.
if (pos < _pos) {
_int = _bit = _pos = 0;
}
// Scan through the bit array - skip integers that have no bits set
for ( ; _int <= _intSize; _int++) {
int bits = _bits[_int];
if (bits != 0) { // Any bits set?
for ( ; _bit < 32; _bit++) {
if ((bits & _masks[_bit]) != 0) {
if (++_pos == pos) {
_node = ((_int << 5) + _bit) - 1;
return (_node);
}
}
}
_bit = 0;
}
}
return(0);
|
public int | getMask()See setMask()
return(_mask);
|
public final int | getNextBit(int startBit)Returns the next set bit from a given position
for (int i = (startBit >>> 5) ; i<=_intSize; i++) {
int bits = _bits[i];
if (bits != 0) {
for (int b = (startBit % 32); b<32; b++) {
if ((bits & _masks[b]) != 0) {
return((i << 5) + b);
}
}
}
startBit = 0;
}
return(DTMAxisIterator.END);
|
public final com.sun.org.apache.xalan.internal.xsltc.dom.BitArray | merge(com.sun.org.apache.xalan.internal.xsltc.dom.BitArray other)Merge two bit arrays. This currently only works for nodes from
a single DOM (because there is only one _mask per array).
// Take other array's bits if we have node set
if (_last == -1) {
_bits = other._bits;
}
// Only merge if other array has any bits set
else if (other._last != -1) {
int start = (_first < other._first) ? _first : other._first;
int stop = (_last > other._last) ? _last : other._last;
// Merge these bits into other array if other array is larger
if (other._intSize > _intSize) {
if (stop > _intSize) stop = _intSize;
for (int i=start; i<=stop; i++)
other._bits[i] |= _bits[i];
_bits = other._bits;
}
// Merge other bits into this array if this arrai is large/equal.
else {
if (stop > other._intSize) stop = other._intSize;
for (int i=start; i<=stop; i++)
_bits[i] |= other._bits[i];
}
}
return(this);
|
public void | readExternal(java.io.ObjectInput in)Read the whole tree from a file (serialized)
_bitSize = in.readInt();
_intSize = (_bitSize >>> 5) + 1;
_mask = in.readInt();
_bits = (int[])in.readObject();
|
public final void | resize(int newSize)Resizes the bit array - try to avoid using this method!!!
if (newSize > _bitSize) {
_intSize = (newSize >>> 5) + 1;
final int[] newBits = new int[_intSize + 1];
System.arraycopy(_bits, 0, newBits, 0, (_bitSize>>>5) + 1);
_bits = newBits;
_bitSize = newSize;
}
|
public final void | setBit(int bit)Sets a given bit // The _INTEGER INDEX_ where last set bit is
if (DEBUG_ASSERTIONS) {
if (bit >= _bitSize) {
throw new Error(
"Programmer's assertion in BitArray.getBit");
}
}
if (bit >= _bitSize) return;
final int i = (bit >>> 5);
if (i < _first) _first = i;
if (i > _last) _last = i;
_bits[i] |= _masks[bit % 32];
|
public void | setMask(int mask)Set the mask for this bit array. The upper 8 bits of this mask
indicate the DOM in which the nodes in this array belong.
_mask = mask;
|
public final int | size()Returns the size of this bit array (in bits).
return(_bitSize);
|
public void | writeExternal(java.io.ObjectOutput out)
out.writeInt(_bitSize);
out.writeInt(_mask);
out.writeObject(_bits);
out.flush();
|