Compile using blc my-file-name.bl
and run ./out
.
#import "std/table"
main :: fn () s32 {
using std;
table: Table(string_view, s32);
defer tbl_terminate(&table);
// Insert some data into the table.
tbl_insert(&table, "Martin", 32);
tbl_insert(&table, "Lisa", 29);
tbl_insert(&table, "John", 40);
// Lookup data by key.
value, found :: tbl_lookup(&table, "Martin");
if found {
print("%\n", value);
}
// Iterate over the table
loop i := 0; i < table.len; i += 1 {
print("[%] %\n", table.keys[i], table.values[i]);
}
return 0;
}