java_cup

Class symbol_set

public class symbol_set extends Object

This class represents a set of symbols and provides a series of set operations to manipulate them.

Version: last updated: 11/25/95

Author: Scott Hudson

See Also: symbol

Field Summary
protected Hashtable_all
A hash table to hold the set.
Constructor Summary
symbol_set()
Constructor for an empty set.
symbol_set(symbol_set other)
Constructor for cloning from another set.
Method Summary
booleanadd(symbol sym)
Add a single symbol to the set.
booleanadd(symbol_set other)
Add (union) in a complete set.
Enumerationall()
Access to all elements of the set.
booleancontains(symbol sym)
Determine if the set contains a particular symbol.
booleanequals(symbol_set other)
Equality comparison.
booleanequals(Object other)
Generic equality comparison.
inthashCode()
Compute a hash code.
booleanis_subset_of(symbol_set other)
Determine if this set is an (improper) subset of another.
booleanis_superset_of(symbol_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(symbol sym)
Remove a single symbol if it is in the set.
voidremove(symbol_set other)
Remove (set subtract) a complete set.
intsize()
size of the set
StringtoString()
Convert to a string.

Field Detail

_all

protected Hashtable _all
A hash table to hold the set. Symbols are keyed using their name string.

Constructor Detail

symbol_set

public symbol_set()
Constructor for an empty set.

symbol_set

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

Parameters: other the set we are cloning from.

Method Detail

add

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

Parameters: sym the symbol we are adding.

Returns: true if this changes the set.

add

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

Parameters: other the set we are adding in.

Returns: true if this changes the set.

all

public Enumeration all()
Access to all elements of the set.

contains

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

Parameters: sym the symbol we are looking for.

equals

public boolean equals(symbol_set other)
Equality comparison.

equals

public boolean equals(Object other)
Generic equality comparison.

hashCode

public int hashCode()
Compute a hash code.

is_subset_of

public boolean is_subset_of(symbol_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(symbol_set other)
Determine if this set is an (improper) superset of another.

Parameters: other the set we are 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(symbol sym)
Remove a single symbol if it is in the set.

Parameters: sym the symbol we are removing.

remove

public void remove(symbol_set other)
Remove (set subtract) a complete set.

Parameters: other the set we are removing.

size

public int size()
size of the set

toString

public String toString()
Convert to a string.