DIRECTORY Asserting, HashTable, IO, Rope; OneToOne: CEDAR DEFINITIONS = BEGIN OneToOne: TYPE = REF OneToOnePrivate; Enumerate: PROC [oto: OneToOne, Consume: PROC [a, b: REF ANY]] = INLINE {oto.Enumerator[oto, Consume]}; Associate: PROC [oto: OneToOne, a, b: REF ANY] = INLINE {oto.Associator[oto, a, b]}; Contradiction: ERROR [oto: OneToOne, a, b: REF ANY]; Map: PROC [oto: OneToOne, from: REF ANY, forward: BOOL _ TRUE] RETURNS [to: REF ANY] = INLINE {to _ oto.Mapper[oto, from, forward]}; CreateVanillaOneToOne: PROC RETURNS [oto: OneToOne]; Reverse: PROC [OneToOne] RETURNS [OneToOne]; Translate: PROC [inner, translator: OneToOne, translateForward: BOOL _ TRUE] RETURNS [outer: OneToOne]; OneToOnePrivate: TYPE = RECORD [ Enumerator: PROC [oto: OneToOne, Consume: PROC [a, b: REF ANY]], Associator: PROC [oto: OneToOne, a, b: REF ANY], Mapper: PROC [oto: OneToOne, from: REF ANY, forward: BOOL _ TRUE] RETURNS [REF ANY], data: REF ANY ]; END. OneToOne.Mesa Last Edited by: Spreitzer, May 7, 1986 4:19:15 pm PDT One-to-One Mappings Represents a one-to-one relation between two sets of non-NIL REF ANYs. Will raise Contradiction if a or b already associated or either is NIL. Returns NIL if no association. Creates a OneToOne with an implementation that is likely to often be OK. xlate = IF translateForward THEN translator ELSE Reverse[translator] outer[ao, bo] W E ai, bi : xlate[ai, ao] & inner[ai, bi] & xlate[bi, bo] Implementing One-To-One Mappings Κ=– "cedar" style˜code™ J™5—K˜KšΟk œœ˜)K˜šΠbxœœ œ˜K˜Kš˜head™šœ œœ˜%K™F—K˜š Οn œœŸœœœœ˜>Kšœœ ˜(—šŸ œœœœ˜.K™GKšœœ˜%KšŸ œœœœ˜4—šŸœœœœ œœœœœ˜TK™Kšœœ'˜/—K˜šŸœœœ˜4K™H—K˜KšŸœœ œ ˜,K˜š Ÿ œœ1œœœ˜gKšœD™DKšœΟdœ œΟmœ‘œ œ œ  œ œ‘œ œ œ‘œ œ œ™H——™ šœœœ˜ Kš Ÿ œœŸœœœœ˜@KšŸ œœœœ˜0KšŸœœœœ œœœœœ˜TKšœœ˜ K˜——K˜Kšœ˜——…—Όύ