Top Description Fields Constructors Methods
org.antlr.runtime

public Class BitSet

extends Object
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Imports
java.util.List

A stripped-down version of org.antlr.misc.BitSet that is just good enough to handle runtime requirements such as FOLLOW sets for automatic error recovery.

Field Summary

Modifier and TypeField and Description
protected static final int
protected long[]
bits

The actual data bits

protected static final int
protected static final int

Constructor Summary

AccessConstructor and Description
public
BitSet()

Construct a bitset of size one word (64 bits)

public
BitSet(long[] bits_)

Construction from a static array of longs

public
BitSet(List<Integer> items)

Construction from a list of integers

public
BitSet(int
The size of the bitset in bits
nbits
)

Construct a bitset given the size

Method Summary

Modifier and TypeMethod and Description
public void
add(int el)

or this element into this set (grow as necessary to accommodate)

private static final long
bitMask(int bitNumber)

public Object
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.
public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public void
growToInclude(int
element that must fit in set
bit
)

Grows the set to a larger number of bits.

public boolean
public int
lengthInLongWords()

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

public boolean
member(int el)

public int
private final int
public static BitSet
of(int el)

public static BitSet
of(int a, int b)

public static BitSet
of(int a, int b, int c)

public static BitSet
of(int a, int b, int c, int d)

public BitSet
or(BitSet a)

return this | a in a new set

public void
public void
remove(int el)

private void
setSize(int
how many words the new set should be
nwords
)

Sets the size of a set.

public int
size()

public int[]
toArray()

Is this contained within a?

public long[]
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public String
toString(String[] tokenNames)

private static final int
wordNumber(int bit)

Inherited from java.lang.Object:
finalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

BITSback to summary
protected static final int BITS
bitsback to summary
protected long[] bits

The actual data bits

LOG_BITSback to summary
protected static final int LOG_BITS
MOD_MASKback to summary
protected static final int MOD_MASK

Constructor Detail

BitSetback to summary
public BitSet()

Construct a bitset of size one word (64 bits)

BitSetback to summary
public BitSet(long[] bits_)

Construction from a static array of longs

BitSetback to summary
public BitSet(List<Integer> items)

Construction from a list of integers

BitSetback to summary
public BitSet(int nbits)

Construct a bitset given the size

Parameters
nbits:int

The size of the bitset in bits

Method Detail

addback to summary
public void add(int el)

or this element into this set (grow as necessary to accommodate)

bitMaskback to summary
private static final long bitMask(int bitNumber)
cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:Object

a clone of this instance.

Annotations
@Override
equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
other:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
growToIncludeback to summary
public void growToInclude(int bit)

Grows the set to a larger number of bits.

Parameters
bit:int

element that must fit in set

isNilback to summary
public boolean isNil()
lengthInLongWordsback to summary
public int lengthInLongWords()

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

memberback to summary
public boolean member(int el)
numBitsback to summary
public int numBits()
numWordsToHoldback to summary
private final int numWordsToHold(int el)
ofback to summary
public static BitSet of(int el)
ofback to summary
public static BitSet of(int a, int b)
ofback to summary
public static BitSet of(int a, int b, int c)
ofback to summary
public static BitSet of(int a, int b, int c, int d)
orback to summary
public BitSet or(BitSet a)

return this | a in a new set

orInPlaceback to summary
public void orInPlace(BitSet a)
removeback to summary
public void remove(int el)
setSizeback to summary
private void setSize(int nwords)

Sets the size of a set.

Parameters
nwords:int

how many words the new set should be

sizeback to summary
public int size()
toArrayback to summary
public int[] toArray()

Is this contained within a?

toPackedArrayback to summary
public long[] toPackedArray()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
toStringback to summary
public String toString(String[] tokenNames)
wordNumberback to summary
private static final int wordNumber(int bit)