Public Member Functions | Static Public Member Functions | Protected Attributes | Static Protected Attributes

antlr.collections.impl.BitSet Class Reference

List of all members.

Public Member Functions

 BitSet ()
 BitSet (long[] bits_)
 BitSet (int nbits)
void add (int el)
BitSet and (BitSet a)
void andInPlace (BitSet a)
void clear ()
void clear (int el)
Object clone ()
int degree ()
boolean equals (Object obj)
void growToInclude (int bit)
boolean member (int el)
boolean nil ()
BitSet not ()
void notInPlace ()
void notInPlace (int maxBit)
void notInPlace (int minBit, int maxBit)
BitSet or (BitSet a)
void orInPlace (BitSet a)
void remove (int el)
int size ()
int lengthInLongWords ()
boolean subset (BitSet a)
void subtractInPlace (BitSet a)
int[] toArray ()
long[] toPackedArray ()
String toString ()
String toString (String separator)
String toString (String separator, CharFormatter formatter)
String toString (String separator, Vector vocabulary)
String toStringOfHalfWords ()
String toStringOfWords ()
String toStringWithRanges (String separator, CharFormatter formatter)

Static Public Member Functions

static Vector getRanges (int[] elems)
static BitSet of (int el)

Protected Attributes

long bits []

Static Protected Attributes

static final int BITS = 64
static final int NIBBLE = 4
static final int LOG_BITS = 6
static final int MOD_MASK = BITS - 1

Detailed Description

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.

Author:
Terence Parr

Pete Wells

Constructor & Destructor Documentation

antlr.collections.impl.BitSet.BitSet (  ) 

Construct a bitset of size one word (64 bits)

References antlr.collections.impl.BitSet.BITS.

Referenced by antlr.collections.impl.BitSet.of().

antlr.collections.impl.BitSet.BitSet ( long[]  bits_  ) 

Construction from a static array of longs

References antlr.collections.impl.BitSet.bits.

antlr.collections.impl.BitSet.BitSet ( int  nbits  ) 

Construct a bitset given the size

Parameters:
nbits The size of the bitset in bits

References antlr.collections.impl.BitSet.bits, and antlr.collections.impl.BitSet.LOG_BITS.


Member Function Documentation

void antlr.collections.impl.BitSet.add ( int  el  ) 
BitSet antlr.collections.impl.BitSet.and ( BitSet  a  ) 
void antlr.collections.impl.BitSet.andInPlace ( BitSet  a  ) 
void antlr.collections.impl.BitSet.clear (  ) 
void antlr.collections.impl.BitSet.clear ( int  el  ) 
Object antlr.collections.impl.BitSet.clone (  ) 
int antlr.collections.impl.BitSet.degree (  ) 
boolean antlr.collections.impl.BitSet.equals ( Object  obj  ) 

code "inherited" from java.util.BitSet

References antlr.collections.impl.BitSet.bits.

Referenced by antlr.CodeGenerator.markBitsetForGen(), and antlr.collections.impl.BitSet.subset().

static Vector antlr.collections.impl.BitSet.getRanges ( int[]  elems  )  [static]

Find ranges in a set element array.

Parameters:
elems The array of elements representing the set, usually from Bit Set.toArray().
Returns:
Vector of ranges.

References antlr.collections.impl.Vector.appendElement().

void antlr.collections.impl.BitSet.growToInclude ( int  bit  ) 
int antlr.collections.impl.BitSet.lengthInLongWords (  ) 

return how much space is being used by the bits array not how many actually have member bits on.

References antlr.collections.impl.BitSet.bits.

boolean antlr.collections.impl.BitSet.member ( int  el  ) 

References antlr.collections.impl.BitSet.bits.

Referenced by antlr.ANTLRParser.alternative(), PascalParser.caseStatement(), antlr.Tool.checkForInvalidArguments(), antlr.preprocessor.Preprocessor.class_def(), SymtabPhase.constList(), PascalTreeParserSuper.constList(), antlr.ANTLRParser.ebnf(), antlr.ANTLRParser.elementNoOptionSpec(), PascalParser.expression(), PascalParser.factor(), PascalParser.fileType(), SymtabPhase.formalParameterList(), PascalTreeParserSuper.formalParameterList(), antlr.CppCodeGenerator.genBitsets(), PascalParser.ifStatement(), antlr.preprocessor.PreprocessorLexer.mACTION(), antlr.actions.python.ActionLexer.mACTION(), antlr.actions.java.ActionLexer.mACTION(), antlr.actions.csharp.ActionLexer.mACTION(), antlr.actions.cpp.ActionLexer.mACTION(), antlr.preprocessor.PreprocessorLexer.mALT(), antlr.actions.python.ActionLexer.mARG(), antlr.actions.java.ActionLexer.mARG(), antlr.actions.csharp.ActionLexer.mARG(), antlr.actions.cpp.ActionLexer.mARG(), antlr.preprocessor.PreprocessorLexer.mARG_ACTION(), antlr.preprocessor.PreprocessorLexer.mASSIGN_RHS(), antlr.actions.python.ActionLexer.mAST_CONSTRUCTOR(), antlr.actions.java.ActionLexer.mAST_CONSTRUCTOR(), antlr.actions.csharp.ActionLexer.mAST_CONSTRUCTOR(), antlr.actions.python.ActionLexer.mAST_CTOR_ELEMENT(), antlr.actions.java.ActionLexer.mAST_CTOR_ELEMENT(), antlr.actions.csharp.ActionLexer.mAST_CTOR_ELEMENT(), antlr.actions.cpp.ActionLexer.mAST_CTOR_ELEMENT(), antlr.actions.python.ActionLexer.mAST_ITEM(), antlr.actions.java.ActionLexer.mAST_ITEM(), antlr.actions.csharp.ActionLexer.mAST_ITEM(), antlr.actions.cpp.ActionLexer.mAST_ITEM(), antlr.actions.python.ActionLexer.mCHAR(), antlr.actions.java.ActionLexer.mCHAR(), antlr.actions.csharp.ActionLexer.mCHAR(), antlr.actions.cpp.ActionLexer.mCHAR(), antlr.preprocessor.PreprocessorLexer.mCHAR_LITERAL(), antlr.ANTLRLexer.mCHAR_LITERAL(), PascalLexer.mCOMMENT_1(), PascalLexer.mCOMMENT_2(), antlr.preprocessor.PreprocessorLexer.mCURLY_BLOCK_SCARF(), antlr.preprocessor.PreprocessorLexer.mELEMENT(), antlr.actions.python.ActionLexer.mID(), antlr.actions.java.ActionLexer.mID(), antlr.actions.csharp.ActionLexer.mID(), antlr.actions.cpp.ActionLexer.mID(), antlr.actions.python.ActionLexer.mID_ELEMENT(), antlr.actions.java.ActionLexer.mID_ELEMENT(), antlr.actions.csharp.ActionLexer.mID_ELEMENT(), antlr.actions.cpp.ActionLexer.mID_ELEMENT(), antlr.preprocessor.PreprocessorLexer.mID_OR_KEYWORD(), antlr.actions.python.ActionLexer.mINT_OR_FLOAT(), antlr.actions.java.ActionLexer.mINT_OR_FLOAT(), antlr.actions.csharp.ActionLexer.mINT_OR_FLOAT(), antlr.actions.cpp.ActionLexer.mINT_OR_FLOAT(), antlr.ANTLRTokdefLexer.mML_COMMENT(), antlr.ANTLRLexer.mML_COMMENT(), antlr.ANTLRLexer.mNESTED_ACTION(), antlr.ANTLRLexer.mNESTED_ARG_ACTION(), antlr.preprocessor.PreprocessorLexer.mRULE_BLOCK(), antlr.ANTLRTokdefLexer.mSL_COMMENT(), antlr.ANTLRLexer.mSL_COMMENT(), antlr.ANTLRTokdefLexer.mSTRING(), antlr.actions.python.ActionLexer.mSTRING(), antlr.actions.java.ActionLexer.mSTRING(), antlr.actions.csharp.ActionLexer.mSTRING(), antlr.actions.cpp.ActionLexer.mSTRING(), antlr.preprocessor.PreprocessorLexer.mSTRING_LITERAL(), PascalLexer.mSTRING_LITERAL(), antlr.ANTLRLexer.mSTRING_LITERAL(), antlr.actions.python.CodeLexer.mSTUFF(), antlr.actions.python.ActionLexer.mSTUFF(), antlr.actions.java.ActionLexer.mSTUFF(), antlr.actions.csharp.ActionLexer.mSTUFF(), antlr.actions.cpp.ActionLexer.mSTUFF(), antlr.preprocessor.PreprocessorLexer.mSUBRULE_BLOCK(), antlr.actions.python.ActionLexer.mTEXT_ARG(), antlr.actions.java.ActionLexer.mTEXT_ARG(), antlr.actions.csharp.ActionLexer.mTEXT_ARG(), antlr.actions.cpp.ActionLexer.mTEXT_ARG(), antlr.actions.python.ActionLexer.mTEXT_ARG_ID_ELEMENT(), antlr.actions.java.ActionLexer.mTEXT_ARG_ID_ELEMENT(), antlr.actions.csharp.ActionLexer.mTEXT_ARG_ID_ELEMENT(), antlr.actions.cpp.ActionLexer.mTEXT_ARG_ID_ELEMENT(), antlr.actions.python.ActionLexer.mTEXT_ITEM(), antlr.actions.java.ActionLexer.mTEXT_ITEM(), antlr.actions.csharp.ActionLexer.mTEXT_ITEM(), antlr.actions.cpp.ActionLexer.mTEXT_ITEM(), antlr.actions.python.ActionLexer.mTREE_ELEMENT(), antlr.actions.java.ActionLexer.mTREE_ELEMENT(), antlr.actions.csharp.ActionLexer.mTREE_ELEMENT(), antlr.actions.cpp.ActionLexer.mTREE_ELEMENT(), antlr.ANTLRLexer.mWS_OPT(), antlr.TokenStreamRewriteEngine.nextToken(), antlr.TokenStreamHiddenTokenFilter.nextToken(), antlr.TokenStreamBasicFilter.nextToken(), antlr.preprocessor.PreprocessorLexer.nextToken(), SymtabPhase.parameterList(), PascalTreeParserSuper.parameterList(), SymtabPhase.recordVariableList(), PascalTreeParserSuper.recordVariableList(), antlr.ANTLRParser.rootNode(), antlr.ANTLRParser.rules(), SymtabPhase.set(), PascalTreeParserSuper.set(), PascalParser.simpleExpression(), PascalParser.simpleStatement(), PascalParser.simpleType(), SymtabPhase.statements(), PascalTreeParserSuper.statements(), PascalParser.tag(), antlr.collections.impl.BitSet.toArray(), antlr.collections.impl.BitSet.toString(), antlr.ANTLRParser.tree(), SymtabPhase.typeList(), PascalTreeParserSuper.typeList(), SymtabPhase.variable(), PascalTreeParserSuper.variable(), and PascalParser.variantPart().

boolean antlr.collections.impl.BitSet.nil (  ) 
BitSet antlr.collections.impl.BitSet.not (  ) 
void antlr.collections.impl.BitSet.notInPlace ( int  minBit,
int  maxBit 
)

complement bits in the range minBit..maxBit.

References antlr.collections.impl.BitSet.bits, and antlr.collections.impl.BitSet.growToInclude().

void antlr.collections.impl.BitSet.notInPlace (  ) 
void antlr.collections.impl.BitSet.notInPlace ( int  maxBit  ) 

complement bits in the range 0..maxBit.

References antlr.collections.impl.BitSet.notInPlace().

static BitSet antlr.collections.impl.BitSet.of ( int  el  )  [static]
BitSet antlr.collections.impl.BitSet.or ( BitSet  a  ) 
void antlr.collections.impl.BitSet.orInPlace ( BitSet  a  ) 
void antlr.collections.impl.BitSet.remove ( int  el  ) 
int antlr.collections.impl.BitSet.size (  ) 
boolean antlr.collections.impl.BitSet.subset ( BitSet  a  ) 
void antlr.collections.impl.BitSet.subtractInPlace ( BitSet  a  ) 

Subtract the elements of 'a' from 'this' in-place. Basically, just turn off all bits of 'this' that are in 'a'.

References antlr.collections.impl.BitSet.bits.

int [] antlr.collections.impl.BitSet.toArray (  ) 
long [] antlr.collections.impl.BitSet.toPackedArray (  ) 
String antlr.collections.impl.BitSet.toString ( String  separator  ) 

Transform a bit set into a string by formatting each element as an integer The string to put in between elements

Returns:
A commma-separated list of values

References antlr.collections.impl.BitSet.bits, antlr.collections.impl.BitSet.LOG_BITS, and antlr.collections.impl.BitSet.member().

String antlr.collections.impl.BitSet.toString (  ) 
String antlr.collections.impl.BitSet.toString ( String  separator,
Vector  vocabulary 
)

Create a string representation where instead of integer elements, the ith element of vocabulary is displayed instead. Vocabulary is a Vector of Strings. The string to put in between elements

Returns:
A commma-separated list of character constants.

References antlr.collections.impl.BitSet.bits, antlr.collections.impl.Vector.elementAt(), antlr.collections.impl.BitSet.LOG_BITS, antlr.collections.impl.BitSet.member(), antlr.collections.impl.Vector.size(), and antlr.collections.impl.BitSet.toString().

String antlr.collections.impl.BitSet.toString ( String  separator,
CharFormatter  formatter 
)

Transform a bit set into a string of characters. The string to put in between elements

Parameters:
formatter An object implementing the CharFormatter interface.
Returns:
A commma-separated list of character constants.

References antlr.collections.impl.BitSet.bits, antlr.CharFormatter.literalChar(), antlr.collections.impl.BitSet.LOG_BITS, and antlr.collections.impl.BitSet.member().

String antlr.collections.impl.BitSet.toStringOfHalfWords (  ) 

Dump a comma-separated list of the words making up the bit set. Split each 64 bit number into two more manageable 32 bit numbers. This generates a comma-separated list of C++-like unsigned long constants.

References antlr.collections.impl.BitSet.bits.

Referenced by antlr.CppCodeGenerator.genBitsets().

String antlr.collections.impl.BitSet.toStringOfWords (  ) 

Dump a comma-separated list of the words making up the bit set. This generates a comma-separated list of Java-like long int constants.

References antlr.collections.impl.BitSet.bits.

String antlr.collections.impl.BitSet.toStringWithRanges ( String  separator,
CharFormatter  formatter 
)

Print out the bit set but collapse char ranges.

References antlr.CharFormatter.literalChar(), and antlr.collections.impl.BitSet.toArray().


Member Data Documentation

final int antlr.collections.impl.BitSet.BITS = 64 [static, protected]
final int antlr.collections.impl.BitSet.LOG_BITS = 6 [static, protected]
final int antlr.collections.impl.BitSet.MOD_MASK = BITS - 1 [static, protected]
final int antlr.collections.impl.BitSet.NIBBLE = 4 [static, protected]

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Enumerations Properties