From 46439007cf417cbd9ac8049bb4122c890097a0fa Mon Sep 17 00:00:00 2001 From: "Charles.Forsyth" Date: Fri, 22 Dec 2006 20:52:35 +0000 Subject: 20060303-partial --- module/strinttab.m | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 module/strinttab.m (limited to 'module/strinttab.m') diff --git a/module/strinttab.m b/module/strinttab.m new file mode 100644 index 00000000..936dcb3b --- /dev/null +++ b/module/strinttab.m @@ -0,0 +1,17 @@ +StringIntTab: module +{ + PATH: con "/dis/lib/strinttab.dis"; + + StringInt: adt{ + key: string; + val: int; + }; + + # Binary search of t (which must be sorted) for key. + # Returns (found, val). + lookup: fn(t: array of StringInt, key: string) : (int, int); + + # Linear search of t for first pair with given val. + # Returns key (nil if no match). + revlookup: fn(t: array of StringInt, val: int) : string; +}; -- cgit v1.2.3