Hash_Table module

table_reset_keeping_memory

procedureSource

Removes every entry but keeps the allocated slots, so refilling the table up to its old size allocates nothing.

Costs time linear in the slot count. Values are not freed; if they own memory, free it first.

Example↗
table: Table(int, int);
table_add(*table, 1, 1);
slots := table.allocated;
table_reset_keeping_memory(*table);
assert(table.count == 0 && table.allocated == slots);
deinit(*table);
table_reset_keeping_memory :: (table: *Table)

Parameters

table: *Table

See also