DIRECTORY HashTable; LichenSetTheory: CEDAR DEFINITIONS = BEGIN NotMutable: ERROR; Mapper: TYPE = REF MapperPrivate; MapperPrivate: TYPE = RECORD [ class: MapperClass, mutable: BOOL _ TRUE, data: REF ANY]; MapperClass: TYPE = REF MapperClassPrivate; MapperClassPrivate: TYPE = RECORD [ Map: PROC [m: Mapper, domain: REF ANY] RETURNS [range: REF ANY], SetMapping: PROC [m: Mapper, domain, range: REF ANY] RETURNS [hadMapping: BOOL], Enumerate: PROC [m: Mapper, Consume: PROC [domain, range: REF ANY]], Size: PROC [m: Mapper] RETURNS [INT] ]; Map: PROC [mapper: Mapper, arg: REF ANY] RETURNS [result: REF ANY] = INLINE {result _ mapper.class.Map[mapper, arg]}; SetMapping: PROC [mapper: Mapper, domain, range: REF ANY] RETURNS [hadMapping: BOOL] = INLINE {IF NOT mapper.mutable THEN NotMutable[] ELSE hadMapping _ mapper.class.SetMapping[mapper, domain, range]}; EnumerateMapping: PROC [mapper: Mapper, Consume: PROC [domain, range: REF ANY]] = INLINE {mapper.class.Enumerate[mapper, Consume]}; MapSize: PROC [mapper: Mapper] RETURNS [size: INT] = INLINE {size _ mapper.class.Size[mapper]}; FreezeMapper: PROC [mapper: Mapper] = INLINE {mapper.mutable _ FALSE}; CreateHashMapper: PROC [equal: HashTable.EqualProc _ NIL, hash: HashTable.HashProc _ NIL] RETURNS [m: Mapper]; CreateHashDictionary: PROC [caseSensitive: BOOL] RETURNS [m: Mapper]; Set: TYPE = REF SetPrivate; SetPrivate: TYPE = RECORD [ class: SetClass _ NIL, mutable: BOOL _ TRUE, data: REF ANY _ NIL]; SetClass: TYPE = REF SetClassPrivate; SetClassPrivate: TYPE = RECORD [ TestMembership: PROC [set: Set, elt: REF ANY] RETURNS [BOOL], UnionSingleton: PROC [set: Set, elt: REF ANY] RETURNS [new: BOOL], UnionSet: PROC [self, other: Set], RemoveElt: PROC [set: Set, elt: REF ANY], Enumerate: PROC [set: Set, Consumer: PROC [REF ANY]], Size: PROC [set: Set] RETURNS [INT] ]; DontUnionSingleton: PROC [set: Set, elt: REF ANY] RETURNS [new: BOOL]; DontUnionSet: PROC [self, other: Set]; DontRemoveElt: PROC [set: Set, elt: REF ANY]; HasMember: PROC [set: Set, elt: REF ANY] RETURNS [BOOL] = INLINE {RETURN[set.class.TestMembership[set, elt]]}; UnionSingleton: PROC [set: Set, elt: REF ANY] RETURNS [new: BOOL] = INLINE {IF NOT set.mutable THEN NotMutable[] ELSE new _ set.class.UnionSingleton[set, elt]}; UnionSet: PROC [self, other: Set] = INLINE {IF NOT self.mutable THEN NotMutable[] ELSE self.class.UnionSet[self, other]}; RemoveElt: PROC [set: Set, elt: REF ANY] = INLINE {IF NOT set.mutable THEN NotMutable[] ELSE set.class.RemoveElt[set, elt]}; Enumerate: PROC [set: Set, Consumer: PROC [REF ANY]] = INLINE {set.class.Enumerate[set, Consumer]}; Size: PROC [set: Set] RETURNS [INT] = INLINE {RETURN[set.class.Size[set]]}; FreezeSet: PROC [set: Set] = INLINE {set.mutable _ FALSE}; DestroySet: PROC [set: Set] = INLINE {set.class _ NIL; set.data _ NIL}; CreateSingleton: PROC [elt: REF ANY] RETURNS [set: Set]; CreateHashSet: PROC [equal: HashTable.EqualProc _ NIL, hash: HashTable.HashProc _ NIL] RETURNS [set: Set]; SetList: TYPE = LIST OF Set; CreateUnion: PROC [sets: SetList, eltsImmutable: BOOL _ TRUE] RETURNS [Set]; END. ŒLichenSetTheory.Mesa Last Edited by: Spreitzer, June 13, 1986 2:21:52 pm PDT If eltsImmutable, the sets cannot change their contents. Κf– "cedar" style˜code™J™7—K˜KšΟk œ ˜K˜šΠbxœœ œ˜$Kš˜K˜KšΠbl œœ˜K˜Kšœœœ˜!šœœœ˜K˜Kšœ œœ˜Kšœœœ˜—K˜Kšœ œœ˜+šœœœ˜#KšΟnœœœœœ œœ˜@Kš   œœœœœœ˜PKš   œœ  œœœœ˜DKš œœ œœ˜$K˜—K˜š œœœœœ œœ˜BKšœœ*˜2—š   œœ!œœœœ˜TKš œœœœœœ>˜t—š  œœ œœœœ˜OKšœœ+˜3—š œœœœ˜2Kšœœ$˜,—š  œœ˜#Kšœœœ˜"—K˜Kš  œœœœœ ˜nKš œœœœ ˜EK˜Kšœœœ ˜šœ œœ˜Kšœœ˜Kšœ œœ˜Kšœœœœ˜—K˜Kšœ œœ˜%šœœœ˜ Kš  œœœœœœ˜=Kš  œœœœœœ˜BKš œœ˜"Kš  œœœœ˜)Kš   œœ  œœœœ˜5Kš œœ œœ˜#K˜—K˜Kš  œœœœœœ˜FKš  œœ˜&Kš  œœœœ˜-K˜š   œœœœœœ˜7Kšœœœ&˜6—š  œœœœœœ˜AKš œœœœ œœ+˜^—š œœ˜!Kš œœœœœœ#˜W—š  œœœœ˜(Kš œœœœ œœ ˜S—š   œœ  œœœœ˜4Kšœœ&˜.—š œœ œœ˜#Kšœœœ˜'—š  œœ ˜Kšœœœ˜—š  œœ ˜Kšœœœ œ˜+—K˜Kš  œœœœœ ˜8K˜Kš   œœœœœ ˜jK˜Kšœ œœœ˜K˜š   œœ œœœ˜LKšœΟe œ‘œ™8—K˜Kšœ˜——…— $