TIPFastTablesImpl.mesa
Copyright Ó 1988, 1991 by Xerox Corporation. All rights reserved.
Bier, March 4, 1993 12:39 pm PST
Christian Jacobi, February 18, 1992 8:08 pm PST
Contents: Routines for creating and accessing fast TIP tables. Formerly called TIPTableAccessImpl.
DIRECTORY
CardTab, KeyTypes, TIPFastTables, TIPTables;
TIPFastTablesImpl:
CEDAR
PROGRAM
IMPORTS CardTab
EXPORTS TIPFastTables = BEGIN
KeySym: TYPE = KeyTypes.KeySym;
TIPChoice: TYPE = TIPTables.TIPChoice;
TIPFastTable: TYPE = TIPTables.TIPFastTable;
CreateFastTable:
PUBLIC
PROC [mod:
NAT ¬ 73]
RETURNS [fastTable: TIPFastTable] = {
fastTable ¬ CardTab.Create[mod];
};
GetSizeFastTable:
PUBLIC
PROC [fastTable: TIPFastTable]
RETURNS [
CARD] = {
RETURN[CardTab.GetSize[fastTable]];
};
StoreInFastTable:
PUBLIC
PROC [fastTable: TIPFastTable, keySym: KeySym, choice: TIPChoice] = {
[] ¬ CardTab.Store[fastTable, keySym, choice];
};
FetchFromFastTable:
PUBLIC
PROC [fastTable: TIPFastTable, keySym: KeySym]
RETURNS [choice: TIPChoice] = {
found: BOOL ¬ FALSE;
val: CardTab.Val;
[found, val] ¬ CardTab.Fetch[fastTable, keySym];
choice ¬ IF found THEN NARROW[val] ELSE NIL;
};
WalkKeySymsInFastTable:
PUBLIC PROC [fastTable: TIPTables.TIPFastTable, proc:
PROC [k: KeySym, c: TIPChoice]] = {
Apply proc to each of the TIPChoices in fastTable.
DoProc:
PROC [key: CardTab.Key, val: CardTab.Val]
RETURNS [quit:
BOOL ¬
FALSE] = {
choice: TIPChoice ¬ NARROW[val];
proc[[key], choice];
};
[] ¬ CardTab.Pairs[fastTable, DoProc];
};
END.