Package org.apache.derby.iapi.util
Class JBitSet
java.lang.Object
org.apache.derby.iapi.util.JBitSet
JBitSet is a wrapper class for BitSet. It is a fixed length implementation
which can be extended via the grow() method. It provides additional
methods to manipulate BitSets.
NOTE: JBitSet was driven by the (current and perceived) needs of the
optimizer, but placed in the util package since it is not specific to
query trees..
NOTE: java.util.BitSet is final, so we must provide a wrapper class
which includes a BitSet member in order to extend the functionality.
We want to make it look like JBitSet extends BitSet, so we need to
provide wrapper methods for all of BitSet's methods.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
clear
(int bitIndex) void
clearAll()
Clear all of the bits in this JBitSetclone()
boolean
Test to see if one JBitSet contains another one of the same size.boolean
boolean
get
(int bitIndex) int
Get the first set bit (starting at index 0) from a JBitSet.void
grow
(int newSize) Grow an existing JBitSet to the specified size.int
hashCode()
boolean
See of a JBitSet has exactly 1 bit set.void
void
set
(int bitIndex) void
Set the BitSet to have the exact same bits set as the parameter's BitSet.int
size()
Return the size of bitSettoString()
void
-
Field Details
-
bitSet
-
size
private int size
-
-
Constructor Details
-
JBitSet
public JBitSet(int size) Construct a JBitSet of the specified size.- Parameters:
size
- The number of bits in the JBitSet.
-
JBitSet
Construct a JBitSet with the specified bitSet.- Parameters:
bitSet
- The BitSet.size
- The size of bitSet. NOTE: We need to specify the size since the size of a BitSet is not guaranteed to be the same as JBitSet.size().
-
-
Method Details
-
setTo
Set the BitSet to have the exact same bits set as the parameter's BitSet.- Parameters:
sourceBitSet
- The JBitSet to copy.
-
contains
Test to see if one JBitSet contains another one of the same size.- Parameters:
jBitSet
- JBitSet that we want to know if it is a subset of current JBitSet- Returns:
- boolean Whether or not jBitSet is a subset.
-
hasSingleBitSet
public boolean hasSingleBitSet()See of a JBitSet has exactly 1 bit set.- Returns:
- boolean Whether or not JBitSet has a single bit set.
-
getFirstSetBit
public int getFirstSetBit()Get the first set bit (starting at index 0) from a JBitSet.- Returns:
- int Index of first set bit, -1 if none set.
-
grow
public void grow(int newSize) Grow an existing JBitSet to the specified size.- Parameters:
newSize
- The new size
-
clearAll
public void clearAll()Clear all of the bits in this JBitSet -
toString
-
equals
-
hashCode
public int hashCode() -
clone
-
get
public boolean get(int bitIndex) -
set
public void set(int bitIndex) -
clear
public void clear(int bitIndex) -
and
-
or
-
xor
-
size
public int size()Return the size of bitSet- Returns:
- int Size of bitSet
-