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
-
list
- The actual list of Symbols.
-
SymbolTable()
-
-
SymbolTable(int)
-
-
SymbolTable(int, int)
-
-
addElement(Symbol)
- Adds the given symbol to the table.
-
elements()
- A wrapper for
Vector.elements().
-
exists(String)
- Returns true if the given name is in the symbol table.
-
getElement(String)
- Returns the symbol associated with the given name.
-
removeElement(String)
- Removes a symbol from the table.
list
Vector list
- The actual list of Symbols.
SymbolTable
public SymbolTable(int initialCapacity,
int capacityIncrement)
SymbolTable
public SymbolTable(int initialCapacity)
SymbolTable
public SymbolTable()
elements
public Enumeration elements()
- A wrapper for
Vector.elements().
exists
public boolean exists(String name)
- Returns true if the given name is in the symbol table.
addElement
public void addElement(Symbol t) throws DuplicateNameException
- Adds the given symbol to the table.
- Throws: DuplicateNameException
- if the symbol is already defined.
getElement
public Symbol getElement(String name) throws NameNotFoundException
- Returns the symbol associated with the given name.
- Throws: NameNotFoundException
- if the symbol is not defined.
removeElement
public Symbol removeElement(String name) throws NameNotFoundException
- Removes a symbol from the table.
- Throws: NameNotFoundException
- if the symbol is not defined.