CardToCardTab: CEDAR DEFINITIONS = BEGIN Ref: TYPE = REF CardToCardTabRep; CardToCardTabRep: TYPE = MONITORED RECORD [impl: REF CardToCardTabImplRep]; CardToCardTabImplRep: TYPE; Key: TYPE = CARD; Val: TYPE = CARD; EqualProc: TYPE = PROC [key1, key2: Key] RETURNS [BOOL]; HashProc: TYPE = PROC [key: Key] RETURNS [CARDINAL]; Create: PROC [mod: NAT ฌ 17, equal: EqualProc ฌ NIL, hash: HashProc ฌ NIL] RETURNS [Ref]; GetSize: PROC [x: Ref] RETURNS [INT]; Fetch: PROC [x: Ref, key: Key, default: Val ฌ Val.LAST] RETURNS [found: BOOL, val: Val]; Replace: PROC [x: Ref, key: Key, val: Val] RETURNS [BOOL]; Store: PROC [x: Ref, key: Key, val: Val] RETURNS [BOOL]; Insert: PROC [x: Ref, key: Key, val: Val] RETURNS [BOOL]; Delete: PROC [x: Ref, key: Key] RETURNS [BOOL]; Erase: PROC [x: Ref]; EachPairAction: TYPE = PROC [key: Key, val: Val] RETURNS [quit: BOOL ฌ FALSE]; Pairs: PROC [x: Ref, action: EachPairAction] RETURNS [BOOL]; UpdateOperation: TYPE = {none, store, delete}; UpdateAction: TYPE = PROC [found: BOOL, val: Val] RETURNS [op: UpdateOperation ฌ none, new: Val ฌ Val.LAST]; Update: PROC [x: Ref, key: Key, action: UpdateAction]; Copy: PROC [x: Ref] RETURNS [Ref]; END. š CardToCardTab.mesa Copyright ำ 1990, 1992 by Xerox Corporation. All rights reserved. Last tweaked by Mike Spreitzer on October 16, 1990 9:37:48 am PDT A CardToCardTab is a hash table which associates CARD keys with CARD values. CardToCardTab is like RefTab and SymTab except for the Key and Val types. ... creates new table with suggested hash size. When equal=NIL, the keys are compared with `key1=key2'. When hash=NIL, some reasonable hash function is used. ... returns number of key-value pairs in table (use this to properly deal with monitored data in preference to using the size field) ... looks up key in table, returns associated value (if any) if found = TRUE, val = value associated with given key if found = FALSE, val = default ... replaces value for existing key; returns TRUE if previous value overwritten; if no previous value for key, returns FALSE without inserting new pair ... stores new key-value pair, overwriting previous value for given key; returns TRUE if new value, FALSE if previous value overwritten ... inserts new key-value pair, except if previous value for given key; returns TRUE if inserted, FALSE if previous value for key ... deletes key-value pair associated with given key; returns TRUE if deletion actually occurred, FALSE if no such key ... deletes all key-value pairs in the table ... enumerates pairs currently in symbol table in unspecified order; pairs inserted/deleted during enumeration may or may not be seen; applies action to each pair until action returns TRUE or no more pairs; returns TRUE if some action returns TRUE ... atomically performs an update action; looks up key and calls action, which returns the desired operation. If op=none, the table is not changed; if op=store, the new value is stored; if op=delete, key is removed from the table. ... atomically copies the table. Carl Hauser, January 14, 1988 2:27:48 pm PST Folded in CedarChest7.0's RefTabExtras interface ส,•NewlineDelimiter –(cedarcode) style™codešœ™Kšœ ฯeœ7™BK™A—K˜Kšœ—™—K™šฯn œฯkœŸ œŸ˜(K˜KšœŸœŸœ˜!Kš œŸœŸ œŸœŸœ˜KKšœŸœ˜K˜KšœŸœŸœ˜KšœŸœŸœ˜K˜Kš œ ŸœŸœŸœŸœ˜8Kš œ ŸœŸœ ŸœŸœ˜4K˜š žœŸœŸœŸœŸœŸœ˜YKšœ/™/K™7K™5K˜—K˜šžœŸœ ŸœŸœ˜%Kšœ„™„K˜—š žœŸœ'ŸœŸœ Ÿœ ˜XKšœ<™Ÿœ Ÿœ™vK˜—šžœŸœ ˜Kšœ,™,K™—K˜š œŸœŸœŸœŸœŸœ˜NK™—šžœŸœ"ŸœŸœ˜