OneToOne.Mesa
Last tweaked by Mike Spreitzer on April 2, 1987 3:07:12 pm PST
DIRECTORY Asserting, IO, RefTab, Rope;
OneToOne: CEDAR DEFINITIONS =
BEGIN
One-to-One Mappings
OneToOne: TYPE = REF OneToOnePrivate;
Represents a one-to-one relation between two sets of non-NIL REF ANYs.
Enumerate: PROC [oto: OneToOne, Consume: PROC [a, b: REF ANY]]
= INLINE {oto.Enumerator[oto, Consume]};
Associate: PROC [oto: OneToOne, a, b: REF ANY]
Will raise Contradiction if a or b already associated or either is NIL.
= INLINE {oto.Associator[oto, a, b]};
Contradiction: ERROR [oto: OneToOne, a, b: REF ANY];
Map: PROC [oto: OneToOne, from: REF ANY, forward: BOOLTRUE] RETURNS [to: REF ANY]
Returns NIL if no association.
= INLINE {to ← oto.Mapper[oto, from, forward]};
CreateVanillaOneToOne: PROC [hashA, hashB: RefTab.HashProc ← NIL, compareA, compareB: RefTab.EqualProc ← NIL] RETURNS [oto: OneToOne];
Creates a OneToOne with an implementation that is likely to often be OK.
id: READONLY OneToOne;
equality of REF.
Reverse: PROC [OneToOne] RETURNS [OneToOne];
Triplate: PROC [inward, inner, outward: OneToOne] RETURNS [outer: OneToOne];
outer[ao, bo] {  ai, bi : inward[ao, ai] ' inner[ai, bi] ' outward[bi, bo]
outer.Associate will be translated to inner.Associate
Implementing One-To-One Mappings
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: BOOLTRUE] RETURNS [REF ANY],
data: REF ANY
];
END.