An indexed table can be the target of an assignment:
b[131.243.1.10, 80/tcp] = c$id;
You can also assign to an entire table. For example, suppose we have the global:
global active_conn_count: table[addr, port] of count;
then we could later clear the contents of the table using:
local empty_table: table[addr, port] of count; active_conn_count = empty_table;
Here the first statement declares a local variable empty_table
with the same type as active_conn_count
. Since we don't
initialize the table, it starts out empty. Assigning it to
active_conn_count
then replaces the value of active_conn_count
with an empty table.
Note: As with record
's, assigning table
values results
in a shallow copy
.
In addition to directly accessing an element of a table by specifying its index, you can also loop over all of the indices in a table using the statement.