IntToIntTab: CEDAR DEFINITIONS = BEGIN Table: TYPE = REF IntToIntTabRep; IntToIntTabRep: TYPE = MONITORED RECORD [impl: REF IntToIntTabImplRep]; IntToIntTabImplRep: TYPE; Key: TYPE = INT; Val: TYPE = INT; Create: PROC [mod: NAT ¬ 17] RETURNS [Table]; GetSize: PROC [table: Table] RETURNS [INT]; Fetch: PROC [table: Table, key: Key] RETURNS [found: BOOL, val: Val]; Replace: PROC [table: Table, key: Key, val: Val] RETURNS [BOOL]; Store: PROC [table: Table, key: Key, val: Val] RETURNS [BOOL]; Insert: PROC [table: Table, key: Key, val: Val] RETURNS [BOOL]; Delete: PROC [table: Table, key: Key] RETURNS [BOOL]; Erase: PROC [table: Table]; EachPairAction: TYPE = PROC [key: Key, val: Val] RETURNS [quit: BOOL ¬ FALSE]; Pairs: PROC [table: Table, action: EachPairAction] RETURNS [BOOL]; UpdateOperation: TYPE = {none, store, delete}; UpdateAction: TYPE = PROC [found: BOOL, val: Val] RETURNS [op: UpdateOperation ¬ none, new: Val ¬ -1]; Update: PROC [table: Table, key: Key, action: UpdateAction]; Copy: PROC [table: Table] RETURNS [Table]; END. π IntToIntTab.mesa Copyright Σ 1987, 1991 by Xerox Corporation. All rights reversed. Christian Jacobi, May 13, 1987 10:43:20 am PDT A IntToIntTab is a hash table which associates INT keys with INT values. IntToIntTab is like RefTab except for the Key and Val types. creates new table with suggested initial hash size returns number of key-value pairs in table looks up key in table, returns associated value (if any) if found is TRUE, val is value associated with given key if found is FALSE, val is -1 returns TRUE after overwriting old value for existing key-value pair if no previous value for key, returns FALSE without inserting new pair returns TRUE after inserting new pair returns FALSE after overwriting old value for existing key-value pair returns TRUE after inserted new pair if previous value existed for key, returns FALSE without changing value 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 given table enumerates pairs currently in 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. ΚΠ–(cedarcode) style•NewlineDelimiter ™codešœ™Kšœ Οeœ6™BKšœ.™.—K˜Kšœ/Οkœ žœF™†K™šΟn œžœž œž˜&K˜šœžœžœ˜!Kš œžœž œžœžœ˜GKšœžœ˜K˜—Kšœžœžœ˜Kšœžœžœ˜K˜šŸœžœžœžœ ˜-Kšœ2™2K˜—šŸœžœžœžœ˜+Kšœ*™*K˜—šŸœžœžœ žœ ˜EKšœ8™8Kšœ8™8Kšœ™K˜—šŸœžœ$žœžœ˜@KšœD™DKšœF™FK˜—šŸœžœ$žœžœ˜>Kšœ%™%KšœE™EK˜—šŸœžœ$žœžœ˜?Kšœ$™$KšœG™GK˜—šŸœžœžœžœ˜5Kšœ0™0Kšœ@™@K˜—šŸœžœ˜K™*—K˜š œžœžœžœžœžœ˜NK™—šŸœžœ(žœžœ˜BKšœ8™8Kšœ@™@KšœF™FKšœ(™(—K˜šœžœ˜.K™—š œžœžœ žœ žœ-˜gK™—šŸœžœ0˜