xref: /inferno-os/module/tables.m (revision 46439007cf417cbd9ac8049bb4122c890097a0fa)
1Tables: module {
2	PATH: con "/dis/lib/tables.dis";
3	Table: adt[T] {
4		items:	array of list of (int, T);
5		nilval:	T;
6
7		new: fn(nslots: int, nilval: T): ref Table[T];
8		add:	fn(t: self ref Table, id: int, x: T): int;
9		del:	fn(t: self ref Table, id: int): int;
10		find:	fn(t: self ref Table, id: int): T;
11	};
12
13	Strhash: adt[T] {
14		items:	array of list of (string, T);
15		nilval:	T;
16
17		new: fn(nslots: int, nilval: T): ref Strhash[T];
18		add:	fn(t: self ref Strhash, id: string, x: T);
19		del:	fn(t: self ref Strhash, id: string);
20		find:	fn(t: self ref Strhash, id: string): T;
21	};
22
23	hash: fn(s: string, n: int): int;
24};
25