DIRECTORY Asserting, IO, RefTab, 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 [hashA, hashB: RefTab.HashProc _ NIL, compareA, compareB: RefTab.EqualProc _ NIL] RETURNS [oto: OneToOne]; id: READONLY OneToOne; Reverse: PROC [OneToOne] RETURNS [OneToOne]; Triplate: PROC [inward, inner, outward: OneToOne] 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 tweaked by Mike Spreitzer on April 2, 1987 3:07:12 pm PST 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. equality of REF. outer[ao, bo] W E ai, bi : inward[ao, ai] & inner[ai, bi] & outward[bi, bo] outer.Associate will be translated to inner.Associate Implementing One-To-One Mappings ΚL– "cedar" style˜code™ K™>—K˜KšΟk œ œ˜&K˜šΠbxœœ œ˜K˜Kš˜head™šœ œœ˜%K™F—K˜š Οn œœŸœœœœ˜>Kšœœ ˜(—šŸ œœœœ˜.K™GKšœœ˜%KšŸ œœœœ˜4—šŸœœœœ œœœœœ˜TK™Kšœœ'˜/—K˜š Ÿœœ"œ)œœ˜†K™H—K˜šœœ ˜K™—K˜KšŸœœ œ ˜,K˜šŸœœ$œ˜LKšœΟdœ œΟmœ‘œ œ œ  œ œ‘œ œ œ‘œ  œ œ™KK™5——™ šœœœ˜ Kš Ÿ œœŸœœœœ˜@KšŸ œœœœ˜0KšŸœœœœ œœœœœ˜TKšœœ˜ K˜——K˜Kšœ˜——…—f