Top Description Fields Constructors Methods
java_cup

public Class symbol_set

extends Object
Class Inheritance
Imports
java.util.Hashtable, .Enumeration

This class represents a set of symbols and provides a series of set operations to manipulate them.
Author
Scott Hudson
Version
last updated: 11/25/95
See Also
java_cup.symbol

Field Summary

Modifier and TypeField and Description
protected Hashtable<K, V>
_all

A hash table to hold the set.

Constructor Summary

AccessConstructor and Description
public
symbol_set()

Constructor for an empty set.

public
symbol_set(symbol_set
the set we are cloning from.
other
)

Constructor for cloning from another set.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if this changes the set.
add
(symbol
the symbol we are adding.
sym
)

Add a single symbol to the set.

public boolean

Returns:

true if this changes the set.
add
(symbol_set
the set we are adding in.
other
)

Add (union) in a complete set.

public Enumeration<E>
all()

Access to all elements of the set.

public boolean
contains(symbol
the symbol we are looking for.
sym
)

Determine if the set contains a particular symbol.

public boolean
equals(symbol_set other)

Equality comparison.

public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Generic equality comparison.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Compute a hash code.
public boolean
is_subset_of(symbol_set
the set we are testing against.
other
)

Determine if this set is an (improper) subset of another.

public boolean
is_superset_of(symbol_set
the set we are are testing against.
other
)

Determine if this set is an (improper) superset of another.

protected void
not_null(Object
the object we are testing.
obj
)

Helper function to test for a null object and throw an exception if one is found.

public void
remove(symbol
the symbol we are removing.
sym
)

Remove a single symbol if it is in the set.

public void
remove(symbol_set
the set we are removing.
other
)

Remove (set subtract) a complete set.

public int
size()

size of the set

public String
toString()

Overrides java.lang.Object.toString.

Convert to a string.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

_allback to summary
protected Hashtable<K, V> _all

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

Constructor Detail

symbol_setback to summary
public symbol_set()

Constructor for an empty set.

symbol_setback to summary
public symbol_set(symbol_set other) throws internal_error

Constructor for cloning from another set.

Parameters
other:symbol_set

the set we are cloning from.

Method Detail

addback to summary
public boolean add(symbol sym) throws internal_error

Add a single symbol to the set.

Parameters
sym:symbol

the symbol we are adding.

Returns:boolean

true if this changes the set.

addback to summary
public boolean add(symbol_set other) throws internal_error

Add (union) in a complete set.

Parameters
other:symbol_set

the set we are adding in.

Returns:boolean

true if this changes the set.

allback to summary
public Enumeration<E> all()

Access to all elements of the set.

containsback to summary
public boolean contains(symbol sym)

Determine if the set contains a particular symbol.

Parameters
sym:symbol

the symbol we are looking for.

equalsback to summary
public boolean equals(symbol_set other)

Equality comparison.

equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Generic equality comparison.

Parameters
other:Object

Doc from java.lang.Object.equals.

the reference object with which to compare.

Returns:boolean

Doc from java.lang.Object.equals.

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

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Compute a hash code.

Returns:int

Doc from java.lang.Object.hashCode.

a hash code value for this object.

is_subset_ofback to summary
public boolean is_subset_of(symbol_set other) throws internal_error

Determine if this set is an (improper) subset of another.

Parameters
other:symbol_set

the set we are testing against.

is_superset_ofback to summary
public boolean is_superset_of(symbol_set other) throws internal_error

Determine if this set is an (improper) superset of another.

Parameters
other:symbol_set

the set we are are testing against.

not_nullback to summary
protected void not_null(Object obj) throws internal_error

Helper function to test for a null object and throw an exception if one is found.

Parameters
obj:Object

the object we are testing.

removeback to summary
public void remove(symbol sym) throws internal_error

Remove a single symbol if it is in the set.

Parameters
sym:symbol

the symbol we are removing.

removeback to summary
public void remove(symbol_set other) throws internal_error

Remove (set subtract) a complete set.

Parameters
other:symbol_set

the set we are removing.

sizeback to summary
public int size()

size of the set

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Convert to a string.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object.