<> <> 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.