java_cup

Class terminal_set

public class terminal_set extends Object

A set of terminals implemented as a bitset.

Version: last updated: 11/25/95

Author: Scott Hudson

Field Summary
static terminal_setEMPTY
Constant for the empty set.
protected BitSet_elements
Bitset to implement the actual set.
Constructor Summary
terminal_set()
Constructor for an empty set.
terminal_set(terminal_set other)
Constructor for cloning from another set.
Method Summary
booleanadd(terminal sym)
Add a single terminal to the set.
booleanadd(terminal_set other)
Add (union) in a complete set.
booleancontains(terminal sym)
Determine if the set contains a particular terminal.
booleancontains(int indx)
Given its index determine if the set contains a particular terminal.
booleanempty()
Determine if the set is empty.
booleanequals(terminal_set other)
Equality comparison.
booleanequals(Object other)
Generic equality comparison.
booleanintersects(terminal_set other)
Determine if this set intersects another.
booleanis_subset_of(terminal_set other)
Determine if this set is an (improper) subset of another.
booleanis_superset_of(terminal_set other)
Determine if this set is an (improper) superset of another.
protected voidnot_null(Object obj)
Helper function to test for a null object and throw an exception if one is found.
voidremove(terminal sym)
Remove a terminal if it is in the set.
StringtoString()
Convert to string.

Field Detail

EMPTY

public static final terminal_set EMPTY
Constant for the empty set.

_elements

protected BitSet _elements
Bitset to implement the actual set.

Constructor Detail

terminal_set

public terminal_set()
Constructor for an empty set.

terminal_set

public terminal_set(terminal_set other)
Constructor for cloning from another set.

Parameters: other the set we are cloning from.

Method Detail

add

public boolean add(terminal sym)
Add a single terminal to the set.

Parameters: sym the terminal being added.

Returns: true if this changes the set.

add

public boolean add(terminal_set other)
Add (union) in a complete set.

Parameters: other the set being added.

Returns: true if this changes the set.

contains

public boolean contains(terminal sym)
Determine if the set contains a particular terminal.

Parameters: sym the terminal symbol we are looking for.

contains

public boolean contains(int indx)
Given its index determine if the set contains a particular terminal.

Parameters: indx the index of the terminal in question.

empty

public boolean empty()
Determine if the set is empty.

equals

public boolean equals(terminal_set other)
Equality comparison.

equals

public boolean equals(Object other)
Generic equality comparison.

intersects

public boolean intersects(terminal_set other)
Determine if this set intersects another.

Parameters: other the other set in question.

is_subset_of

public boolean is_subset_of(terminal_set other)
Determine if this set is an (improper) subset of another.

Parameters: other the set we are testing against.

is_superset_of

public boolean is_superset_of(terminal_set other)
Determine if this set is an (improper) superset of another.

Parameters: other the set we are testing against.

not_null

protected void not_null(Object obj)
Helper function to test for a null object and throw an exception if one is found.

Parameters: obj the object we are testing.

remove

public void remove(terminal sym)
Remove a terminal if it is in the set.

Parameters: sym the terminal being removed.

toString

public String toString()
Convert to string.