|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.antlr.misc.BitSet
public class BitSet
A BitSet to replace java.util.BitSet. Primary differences are that most set operators return new sets as opposed to oring and anding "in place". Further, a number of operations were added. I cannot contain a BitSet because there is no way to access the internal bits (which I need for speed) and, because it is final, I cannot subclass to add functionality. Consider defining set degree. Without access to the bits, I must call a method n times to test the ith bit...ack! Also seems like or() from util is wrong when size of incoming set is bigger than this.bits.length.
Field Summary | |
---|---|
protected long[] |
bits
The actual data bits |
protected static int |
BITS
|
protected static int |
LOG_BITS
|
protected static int |
MOD_MASK
|
Constructor Summary | |
---|---|
BitSet()
Construct a bitset of size one word (64 bits) |
|
BitSet(int nbits)
Construct a bitset given the size |
|
BitSet(long[] bits_)
Construction from a static array of longs |
Method Summary | |
---|---|
void |
add(int el)
or this element into this set (grow as necessary to accommodate) |
void |
addAll(int[] elements)
|
void |
addAll(IntSet set)
Add all elements from incoming set to this set. |
void |
addAll(java.lang.Iterable elements)
|
IntSet |
and(IntSet a)
Return the intersection of this set with the argument, creating a new set. |
void |
andInPlace(BitSet a)
|
void |
clear()
|
void |
clear(int el)
|
java.lang.Object |
clone()
|
IntSet |
complement()
|
IntSet |
complement(IntSet set)
|
boolean |
equals(java.lang.Object other)
|
int |
getSingleElement()
Get the first element you find and return it. |
void |
growToInclude(int bit)
Grows the set to a larger number of bits. |
boolean |
isNil()
|
int |
lengthInLongWords()
return how much space is being used by the bits array not how many actually have member bits on. |
boolean |
member(int el)
|
void |
notInPlace()
|
void |
notInPlace(int maxBit)
complement bits in the range 0..maxBit. |
void |
notInPlace(int minBit,
int maxBit)
complement bits in the range minBit..maxBit. |
int |
numBits()
|
static BitSet |
of(java.util.Collection elements)
|
static BitSet |
of(int el)
|
static BitSet |
of(IntSet set)
|
static BitSet |
of(java.util.Map elements)
|
IntSet |
or(IntSet a)
return this | a in a new set |
void |
orInPlace(BitSet a)
|
static BitSet |
range(int a,
int b)
|
void |
remove(int el)
remove this element from this set |
int |
size()
Return the size of this set (not the underlying implementation's allocated memory size, for example). |
boolean |
subset(BitSet a)
Is this contained within a? |
IntSet |
subtract(IntSet a)
|
void |
subtractInPlace(BitSet a)
Subtract the elements of 'a' from 'this' in-place. |
int[] |
toArray()
|
java.util.List |
toList()
|
long[] |
toPackedArray()
|
java.lang.String |
toString()
|
java.lang.String |
toString(Grammar g)
Transform a bit set into a string by formatting each element as an integer separator The string to put in between elements |
java.lang.String |
toString(java.lang.String separator,
java.util.List vocabulary)
Create a string representation where instead of integer elements, the ith element of vocabulary is displayed instead. |
java.lang.String |
toStringOfHalfWords()
Dump a comma-separated list of the words making up the bit set. |
java.lang.String |
toStringOfWords()
Dump a comma-separated list of the words making up the bit set. |
java.lang.String |
toStringWithRanges()
|
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final int BITS
protected static final int LOG_BITS
protected static final int MOD_MASK
protected long[] bits
Constructor Detail |
---|
public BitSet()
public BitSet(long[] bits_)
public BitSet(int nbits)
nbits
- The size of the bitset in bitsMethod Detail |
---|
public void add(int el)
add
in interface IntSet
public void addAll(IntSet set)
IntSet
addAll
in interface IntSet
public void addAll(int[] elements)
public void addAll(java.lang.Iterable elements)
public IntSet and(IntSet a)
IntSet
and
in interface IntSet
public void andInPlace(BitSet a)
public void clear()
public void clear(int el)
public java.lang.Object clone()
clone
in class java.lang.Object
public int size()
IntSet
size
in interface IntSet
public boolean equals(java.lang.Object other)
equals
in interface IntSet
equals
in class java.lang.Object
public void growToInclude(int bit)
bit
- element that must fit in setpublic boolean member(int el)
member
in interface IntSet
public int getSingleElement()
getSingleElement
in interface IntSet
public boolean isNil()
isNil
in interface IntSet
public IntSet complement()
public IntSet complement(IntSet set)
complement
in interface IntSet
public void notInPlace()
public void notInPlace(int maxBit)
public void notInPlace(int minBit, int maxBit)
public static BitSet of(int el)
public static BitSet of(java.util.Collection elements)
public static BitSet of(IntSet set)
public static BitSet of(java.util.Map elements)
public static BitSet range(int a, int b)
public IntSet or(IntSet a)
or
in interface IntSet
public void orInPlace(BitSet a)
public void remove(int el)
IntSet
remove
in interface IntSet
public int numBits()
public int lengthInLongWords()
public boolean subset(BitSet a)
public void subtractInPlace(BitSet a)
public IntSet subtract(IntSet a)
subtract
in interface IntSet
public java.util.List toList()
toList
in interface IntSet
public int[] toArray()
public long[] toPackedArray()
public java.lang.String toString()
toString
in interface IntSet
toString
in class java.lang.Object
public java.lang.String toString(Grammar g)
toString
in interface IntSet
public java.lang.String toString(java.lang.String separator, java.util.List vocabulary)
public java.lang.String toStringOfHalfWords()
public java.lang.String toStringOfWords()
public java.lang.String toStringWithRanges()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |