Hash_Table module

table_find

procedure · 1 overloadSource

Looks up key; returns whether it was found and a copy of the value (the default value of the type when it was not).

ExampleOpen in playground ↗
table: Table(int, float);
table_add(*table, 3, 1.5);
found, value := table_find(*table, 3);
assert(found && value == 1.5);
found, value = table_find(*table, 4);
assert(!found && value == 0);
deinit(*table);
table_find :: (
    table: *Table,
    key: table.Key_Type
) -> (success: bool, table.Value_Type)

Looks up key; returns whether it was found and a copy of the value (the default value of the type when it was not).

Parameters

table: *Table
key: table.Key_Type

Returns

success: bool
table.Value_Type
ExampleOpen in playground ↗
table: Table(int, float);
table_add(*table, 3, 1.5);
found, value := table_find(*table, 3);
assert(found && value == 1.5);
found, value = table_find(*table, 4);
assert(!found && value == 0);
deinit(*table);

See also