|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--VariableTable
The VariableTable
class acts in conjunction with the Variable
class. For an introduction as to the nature of this relationship see the
introduction to Variable
.
Field Summary | |
protected int |
capacity
The current maximum number of elements possible |
protected int |
marksCapacity
The current maximum number of marks possible |
protected int |
marksSize
The current number of marks |
protected int |
size
The current number of elements |
protected VariableReference[] |
variables
The elements contained in the table |
Constructor Summary | |
VariableTable()
Creates a new empty table with a capacity of 20 elements |
|
VariableTable(int i)
Creates a new empty table with a capacity of i elements. |
Method Summary | |
void |
add(java.lang.String s)
If s isn't already in the table, a new VariableReference
with a name s and value 0 is added. |
void |
add(VariableReference v)
Adds a VariableReference to the table. |
void |
assign(java.lang.String name,
int value)
Assigns value to the reference of name . |
void |
demark()
Removes all variables from the table added since the last mark() . |
int |
dereference(java.lang.String name)
Returns the value for the variable with name of name . |
boolean |
exists(java.lang.String s)
Same as isInTable(java.lang.String) |
boolean |
isInTable(java.lang.String s)
Checks to see if there is a variable with name s in the table |
void |
mark()
Places a mark in the table. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
protected int capacity
protected int size
protected VariableReference[] variables
protected int marksCapacity
mark()
protected int marksSize
mark()
Constructor Detail |
public VariableTable()
public VariableTable(int i)
Method Detail |
public void add(VariableReference v)
VariableReference
to the table. If there is not room in the table for
the symbol then (in the fashion of Vector
) the capacity is
doubled thereby making space.o
- reference to be addedpublic void add(java.lang.String s)
s
isn't already in the table, a new VariableReference
with a name s
and value 0 is added.s
- name of a variable to addpublic void assign(java.lang.String name, int value)
value
to the reference of name
. If there is no
reference of name
in the table then a new one is added with a value of
value
.name
- the name of the variablevalue
- the value to set name
equal topublic boolean isInTable(java.lang.String s)
s
in the tabletrue
if s
is in the tablepublic boolean exists(java.lang.String s)
isInTable(java.lang.String)
isInTable(java.lang.String)
public int dereference(java.lang.String name)
name
.
If name
is not in the table then a
NotATableElementExcepetion
will be thrown.name
- variable name to dereferncepublic void mark()
public void demark()
mark()
.
If there are no marks then the talbe is cleared.
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |