Package cs2110
Class MapVarTable
java.lang.Object
cs2110.MapVarTable
- All Implemented Interfaces:
VarTable
A VarTable implemented using a Map from the Java Collections Framework.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturn whether variable `name` is currently associated with a value in this table.static MapVarTableempty()Create an empty MapVarTable.doubleReturn the value associated with the variable `name`.names()Return the names of all variables associated with a value in this table.static MapVarTableCreate a MapVarTable associating `value1` with variable `name1`.static MapVarTableCreate a MapVarTable associating `value1` with variable `name1` and `value2` with `name2`.voidAssociate `value` with variable `name` in this table, replacing any previously assigned value.intsize()Return the number of variables associated with values in this table.voidRemove any value associated with variable `name` in this table.
-
Field Details
-
map
-
-
Constructor Details
-
MapVarTable
public MapVarTable()Create an empty MapVarTable.
-
-
Method Details
-
empty
Create an empty MapVarTable. -
of
Create a MapVarTable associating `value1` with variable `name1`. -
of
Create a MapVarTable associating `value1` with variable `name1` and `value2` with `name2`. -
get
Description copied from interface:VarTableReturn the value associated with the variable `name`. Throws UnboundVariableException if `name` is not associated with a value in this table.- Specified by:
getin interfaceVarTable- Throws:
UnboundVariableException
-
set
Description copied from interface:VarTableAssociate `value` with variable `name` in this table, replacing any previously assigned value. -
unset
Description copied from interface:VarTableRemove any value associated with variable `name` in this table. -
contains
Description copied from interface:VarTableReturn whether variable `name` is currently associated with a value in this table. -
size
public int size()Description copied from interface:VarTableReturn the number of variables associated with values in this table. -
names
Description copied from interface:VarTableReturn the names of all variables associated with a value in this table.
-