Package java_cup
Class symbol_set
java.lang.Object
java_cup.symbol_set
This class represents a set of symbols and provides a series of
set operations to manipulate them.
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstructor for an empty set.symbol_set
(symbol_set other) Constructor for cloning from another set. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Add a single symbol to the set.boolean
add
(symbol_set other) Add (union) in a complete set.all()
Access to all elements of the set.boolean
Determine if the set contains a particular symbol.boolean
equals
(symbol_set other) Equality comparison.boolean
Generic equality comparison.int
hashCode()
Compute a hash code.boolean
is_subset_of
(symbol_set other) Determine if this set is an (improper) subset of another.boolean
is_superset_of
(symbol_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 single symbol if it is in the set.void
remove
(symbol_set other) Remove (set subtract) a complete set.int
size()
size of the settoString()
Convert to a string.
-
Field Details
-
_all
A hash table to hold the set. Symbols are keyed using their name string.
-
-
Constructor Details
-
symbol_set
public symbol_set()Constructor for an empty set. -
symbol_set
Constructor for cloning from another set.- Parameters:
other
- the set we are cloning from.- Throws:
internal_error
-
-
Method Details
-
all
Access to all elements of the set. -
size
public int size()size of the set -
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
-
contains
Determine if the set contains a particular symbol.- Parameters:
sym
- the symbol we are looking for.
-
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 are testing against.- Throws:
internal_error
-
add
Add a single symbol to the set.- Parameters:
sym
- the symbol we are adding.- Returns:
- true if this changes the set.
- Throws:
internal_error
-
remove
Remove a single symbol if it is in the set.- Parameters:
sym
- the symbol we are removing.- Throws:
internal_error
-
add
Add (union) in a complete set.- Parameters:
other
- the set we are adding in.- Returns:
- true if this changes the set.
- Throws:
internal_error
-
remove
Remove (set subtract) a complete set.- Parameters:
other
- the set we are removing.- Throws:
internal_error
-
equals
Equality comparison. -
equals
Generic equality comparison. -
hashCode
public int hashCode()Compute a hash code. -
toString
Convert to a string.
-