DIRECTORY Rope, IO, AlgebraClasses; Sets: CEDAR DEFINITIONS ~ BEGIN OPEN Rope, AC: AlgebraClasses; Set: TYPE = AC.Object; SetData: TYPE = LIST OF AC.Object; FamilyOfSetsStructureData: TYPE = REF FamilyOfSetsStructureDataRec; FamilyOfSetsStructureDataRec: TYPE = RECORD [ universe: AC.Object -- the elements of the Structure are the subsets of universe ]; MakeFamilyOfSetsStructure: AC.SequenceStructureConstructor; FamilyOfSetsPrintName: AC.ToRopeOp; FamilyOfSetsShortPrintName: AC.ToRopeOp; IsFamilyOfSetsStructure: AC.UnaryPredicate; Universe: AC.UnaryOp; FamilyOfSetsRecast: AC.BinaryOp; FamilyOfSetsCanRecast: AC.BinaryPredicate; FamilyOfSetsToExpr: AC.ToExprOp; FamilyOfSetsLegalFirstChar: AC.LegalFirstCharOp; FamilyOfSetsRead: AC.ReadOp; FamilyOfSetsFromRope: AC.FromRopeOp; FamilyOfSetsToRope: AC.ToRopeOp; FamilyOfSetsWrite: AC.WriteOp; MakeSet: AC.ListImbedOp; SingleSetStructureData: TYPE = REF SingleSetStructureDataRec; SingleSetStructureDataRec: TYPE = RECORD [ underlyingSet: AC.Object -- the elements of the Structure are the elements of underlyingSet ]; MakeSingleSetStructure: AC.StructureFromSetConstructor; SingleSetPrintName: AC.ToRopeOp; SingleSetShortPrintName: AC.ToRopeOp; IsSingleSetStructure: AC.UnaryPredicate; UnderlyingSet: AC.UnaryOp; SingleSetRecast: AC.BinaryOp; SingleSetCanRecast: AC.BinaryPredicate; SingleSetToExpr: AC.ToExprOp; SingleSetLegalFirstChar: AC.LegalFirstCharOp; SingleSetRead: AC.ReadOp; SingleSetFromRope: AC.FromRopeOp; SingleSetToRope: AC.ToRopeOp; SingleSetWrite: AC.WriteOp; UnderlyingSetUniverseEltFromSSSElt: AC.UnaryOp; SSSEltFromUnderlyingSetUniverseElt: AC.BinaryOp; IsVariable: AC.UnaryPredicate; VariableFromRope: AC.FromRopeOp; IsElement: AC.BinaryPredicate; IsSubset: AC.BinaryPredicate; Cardinality: AC.ElementRankOp; Equal: AC.BinaryPredicate; Union: AC.BinaryOp; Intersection: AC.BinaryOp; Difference: AC.BinaryOp; MapUnaryElementOp: AC.BinaryMixedOp; Select: AC.BinaryOp; First: AC.UnaryOp; Last: AC.UnaryOp; VariableSets: AC.Object; -- public structure that has special $variable method for variable eval (see impl) END. „Sets.mesa Last Edited by: Arnon, April 28, 1987 9:22:37 am PDT Finite subsets of some Structure. Also, create Structures which are such sets. OrderedSets are a subclass. Set Representation The elements of SetData are assumed to be distinct. The empty set is represented by NIL SetData. For OrderedSets, the elements of SetData are assumed to be in increasing order. Instance Data for Family of Sets Structures Operations for Family of Sets Structures arg is a Family of Sets Structure; result is its universe Conversion and IO for Elements of Family of Sets Structures Constructor for Family of Sets Structures Currently no checks for repetitions of elements, or for proper ordering if OrderedSet. Does check that supplied elements actually belong to universe (recasts if necessary). data = NIL => empty set. Instance Data for Single Set Structures Elements of SingleSetStructures are represented as elements of the universe of the FamilyOfSets Structure to which underlyingSet belongs (i.e. same rep as elements of underlyingSet), except that their class fields are reset to point to the SingleSetStructure Operations for Single Set Structures arg is a SingleSetStructure; result is its underlyingSet Conversion and IO for Elements of Single Set Structures secondArg is a Single Set Structure, firstArg is an element of its underlyingSet represented as an element of the underlyingSet's universe. result is (a copy of) firstArg with its class reset to secondArg check whether arg is a variable represented as an element of a SingleSetStructure Get a variable from a rope, and recast it as an element of the SingleSetStructure consisting of itself as the only element Set Predicates firstArg is an Object, and secondArg is a Set. Returns TRUE if firstArg is an element of secondArg. firstArg and secondArg are Sets. Returns TRUE if firstArg is a subset of secondArg. Set Operations firstArg is a Set, secondArg is REF to UnaryOp on its elementStructure, result is Set of results of applications of UnaryOp to elements of firstArg. Note that, by elimination of duplicates, cardinality of result may be less that cardinality of argument. It is assumed that the values of application of UnaryOp to elements of firstArg all belong to the same Structure. If this is an ordered structure, then the elements of the result set should be sorted to give a proper OrderedSet representation. Set Selection (OrderedSets only) firstArg is an OrderedSet, secondArg is an Ints.Int specifying position to select. Returns NIL if can't do. firstArg = OrderedSet, return first element. Return NIL if empty. firstArg = OrderedSet, return last element. Return NIL if empty. Public Structure Κ΅˜Jšœ ™ J™4J˜J˜Jšœl™lJ™šΟk ˜ Icodešœ˜Kšœ˜Kšœ˜—Ihead2šΟnœœ ˜Jšœœœœ˜'headšž™Jšœœœ˜J˜Jš œ œœœœ˜"J˜Jšœ4™4Jšœ.™.JšœQ™Q—šœ+™+Kšœœœ˜Cšœœœ˜-Kšœ œΟc<˜PK˜——™(šžœœ˜;K˜—šžœœ ˜#K˜—šžœœ ˜(K˜—šžœœ˜+J˜—šžœœ ˜Jšœ9™9——šœ;™;šžœœ ˜ J˜—šžœœ˜*J˜—šžœœ ˜ J˜—šžœœ˜0J˜—šžœœ˜J˜—šžœœ ˜$J˜—šžœœ ˜ J˜—Jšžœ ˜—šœ*™*šžœœ ˜JšœV™VJšœU™UJšœ™——šœ'™'Kšœœœ˜=šœœœ˜*Kšœœ ŸB˜\K˜—K˜Kšœ‚™‚—šœ$™$šžœœ˜7K˜—šžœœ ˜ K˜—šžœœ ˜%K˜—šžœœ˜(J˜—šž œœ ˜Jšœ8™8——šœ7™7šžœœ ˜J˜—šžœœ˜'J˜—šžœœ ˜J˜—šžœœ˜-J˜—šž œœ˜J˜—šžœœ ˜!J˜—šžœœ ˜J˜—šžœœ ˜J˜—šž"œœ ˜/K˜—šž"œœ ˜0K™Ν—K˜šž œœ˜K™QK˜—šžœœ ˜ Jšœz™z——šž™šž œœ˜Kšœd™dK™—šžœœ˜KšœS™S——šž™šž œœ˜K˜—šžœœ˜J˜—šžœœ ˜K˜—šž œœ ˜K˜—šž œœ ˜K˜—šžœœ˜$K™”K™hK™τ——šž ™ šžœœ ˜Kšœl™lK˜—šžœœ ˜KšœB™BK˜—šžœœ ˜KšœA™A——šž™Jšž œœ ŸR˜k—J˜Jšœ˜—…—T