Package java_cup
Class terminal_set
java.lang.Object
java_cup.terminal_set
A set of terminals implemented as a bitset.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected BitSet
Bitset to implement the actual set.static final terminal_set
Constant for the empty set. -
Constructor Summary
ConstructorsConstructorDescriptionConstructor for an empty set.terminal_set
(terminal_set other) Constructor for cloning from another set. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Add a single terminal to the set.boolean
add
(terminal_set other) Add (union) in a complete set.boolean
contains
(int indx) Given its index determine if the set contains a particular terminal.boolean
Determine if the set contains a particular terminal.boolean
empty()
Determine if the set is empty.boolean
equals
(terminal_set other) Equality comparison.boolean
Generic equality comparison.boolean
intersects
(terminal_set other) Determine if this set intersects another.boolean
is_subset_of
(terminal_set other) Determine if this set is an (improper) subset of another.boolean
is_superset_of
(terminal_set other) Determine if this set is an (improper) superset of another.protected void
Helper function to test for a null object and throw an exception if one is found.void
Remove a terminal if it is in the set.toString()
Convert to string.
-
Field Details
-
EMPTY
Constant for the empty set. -
_elements
Bitset to implement the actual set.
-
-
Constructor Details
-
terminal_set
public terminal_set()Constructor for an empty set. -
terminal_set
Constructor for cloning from another set.- Parameters:
other
- the set we are cloning from.- Throws:
internal_error
-
-
Method Details
-
not_null
Helper function to test for a null object and throw an exception if one is found.- Parameters:
obj
- the object we are testing.- Throws:
internal_error
-
empty
public boolean empty()Determine if the set is empty. -
contains
Determine if the set contains a particular terminal.- Parameters:
sym
- the terminal symbol we are looking for.- Throws:
internal_error
-
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.
-
is_subset_of
Determine if this set is an (improper) subset of another.- Parameters:
other
- the set we are testing against.- Throws:
internal_error
-
is_superset_of
Determine if this set is an (improper) superset of another.- Parameters:
other
- the set we are testing against.- Throws:
internal_error
-
add
Add a single terminal to the set.- Parameters:
sym
- the terminal being added.- Returns:
- true if this changes the set.
- Throws:
internal_error
-
remove
Remove a terminal if it is in the set.- Parameters:
sym
- the terminal being removed.- Throws:
internal_error
-
add
Add (union) in a complete set.- Parameters:
other
- the set being added.- Returns:
- true if this changes the set.
- Throws:
internal_error
-
intersects
Determine if this set intersects another.- Parameters:
other
- the other set in question.- Throws:
internal_error
-
equals
Equality comparison. -
equals
Generic equality comparison. -
toString
Convert to string.
-