diff options
| author | bhgv <bhgv.empire@gmail.com> | 2018-03-01 16:54:45 +0200 |
|---|---|---|
| committer | bhgv <bhgv.empire@gmail.com> | 2018-03-01 16:54:45 +0200 |
| commit | b786f20bbab5a59046aa78a2c6c2a11536497202 (patch) | |
| tree | 0851ecdec889eb9b7ba3751cc04d4f0b474e4a9e /module/strinttab.m | |
inferno-os tree was separated from the inferno-os-android (separated from the Android driver)
Diffstat (limited to 'module/strinttab.m')
| -rw-r--r-- | module/strinttab.m | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/module/strinttab.m b/module/strinttab.m new file mode 100644 index 0000000..936dcb3 --- /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; +}; |
