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 TypeMethodDescriptionboolean
Return whether variable `name` is currently associated with a value in this table.static MapVarTable
empty()
Create an empty MapVarTable.double
Return the value associated with the variable `name`.names()
Return the names of all variables associated with a value in this table.static MapVarTable
Create a MapVarTable associating `value1` with variable `name1`.static MapVarTable
Create a MapVarTable associating `value1` with variable `name1` and `value2` with `name2`.void
Associate `value` with variable `name` in this table, replacing any previously assigned value.int
size()
Return the number of variables associated with values in this table.void
Remove any value associated with variable `name` in this table.
-
Field Details
-
Constructor Details
-
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:VarTable
Return the value associated with the variable `name`. Throws UnboundVariableException if `name` is not associated with a value in this table.- Specified by:
get
in interfaceVarTable
- Throws:
UnboundVariableException
-
set
Description copied from interface:VarTable
Associate `value` with variable `name` in this table, replacing any previously assigned value. -
unset
Description copied from interface:VarTable
Remove any value associated with variable `name` in this table. -
contains
Description copied from interface:VarTable
Return whether variable `name` is currently associated with a value in this table. -
size
public int size()Description copied from interface:VarTable
Return the number of variables associated with values in this table. -
names
Description copied from interface:VarTable
Return the names of all variables associated with a value in this table.
-