Class SymbolTable

java.lang.Object
   |
   +----SymbolTable

class SymbolTable
extends Object
SymbolTable provids a mapping from string to object. Any object that you want to access by a unique String should be a subclass of Symbol and should be kept in a SymbolTable. SymbolTable will throw a DuplicateNameException if the caller tries to add a Symbol with a name that's already taken.

Author:
Peter Sagerson, petersag@wpi.edu

Variable Index

 o list
The actual list of Symbols.

Constructor Index

 o SymbolTable()
 o SymbolTable(int)
 o SymbolTable(int, int)

Method Index

 o addElement(Symbol)
Adds the given symbol to the table.
 o elements()
A wrapper for Vector.elements().
 o exists(String)
Returns true if the given name is in the symbol table.
 o getElement(String)
Returns the symbol associated with the given name.
 o removeElement(String)
Removes a symbol from the table.

Variables

 o list
 Vector list
The actual list of Symbols.

Constructors

 o SymbolTable
 public SymbolTable(int initialCapacity,
                    int capacityIncrement)
 o SymbolTable
 public SymbolTable(int initialCapacity)
 o SymbolTable
 public SymbolTable()

Methods

 o elements
 public Enumeration elements()
A wrapper for Vector.elements().

 o exists
 public boolean exists(String name)
Returns true if the given name is in the symbol table.

 o addElement
 public void addElement(Symbol t) throws DuplicateNameException
Adds the given symbol to the table.

Throws: DuplicateNameException
if the symbol is already defined.
 o getElement
 public Symbol getElement(String name) throws NameNotFoundException
Returns the symbol associated with the given name.

Throws: NameNotFoundException
if the symbol is not defined.
 o removeElement
 public Symbol removeElement(String name) throws NameNotFoundException
Removes a symbol from the table.

Throws: NameNotFoundException
if the symbol is not defined.