<> <> DIRECTORY Atom, Basics, Collections; PairCollections: CEDAR DEFINITIONS IMPORTS Collections = {OPEN Colls: Collections, Collections; <> Collection: TYPE ~ Colls.Collection; Value: TYPE ~ Colls.Value; Direction: TYPE ~ Colls.Direction; Side: TYPE ~ Colls.Side; BoolPair: TYPE ~ Colls.BoolPair; <> Pair: TYPE ~ ARRAY Side OF Value; noPair: READONLY Pair -- = [noValue, noValue] --; PairColl: TYPE ~ RECORD [class: PairCollClass, data: Value]; <> Cons: PROC [class: PairCollClass, data: REF ANY] RETURNS [PairColl]; <> nilPairColl: PairColl ~ [NIL, NIL]; DeRef: PROC [ra: REF ANY] RETURNS [PairColl] ~ INLINE {RETURN [IF ra#NIL THEN NARROW[ra, REF PairColl]^ ELSE nilPairColl]}; Refify: PROC [pc: PairColl] RETURNS [ref: REF ANY] ~ INLINE {ref _ NEW [PairColl _ pc]}; <> Cant: ERROR [pc: PairColl]; <> QualityOf: PROC [pc: PairColl, op: ATOM, args: ArgList _ NIL] RETURNS [ImplQuality]; <> Can: PROC [pc: PairColl, op: ATOM, args: ArgList _ NIL] RETURNS [BOOL] ~ INLINE {RETURN [QualityOf[pc, op, args]#cant]}; Widen: PROC [pc: PairColl] RETURNS [Collection--of REF Pair--] ~ INLINE {RETURN pc.class.Widen[pc]}; HasPair: PROC [pc: PairColl, pair: Pair] RETURNS [BOOL] ~ INLINE {RETURN pc.class.HasPair[pc, pair]}; OrderStyleOf: PROC [pc: PairColl] RETURNS [OrderStyle] ~ INLINE {RETURN [pc.class.orderStyle]}; Ordering: TYPE ~ RECORD [Compare: PairCompareProc, data: REF ANY, sideCare: SideCare]; PairCompareProc: TYPE ~ PROC [data: REF ANY, elt1, elt2: Pair] RETURNS [Basics.Comparison]; SideCare: TYPE ~ {neither, left, right, both}; unordered: Ordering ~ [NIL, NIL, neither]; OrderBySide: PROC [side: Side, o: Colls.Ordering] RETURNS [Ordering]; OrderByBoth: PROC [highSide: Side, high, low: Colls.Ordering] RETURNS [Ordering]; OrderingOf: PROC [pc: PairColl] RETURNS [Ordering] ~ INLINE {RETURN pc.class.OrderingOf[pc]}; CaresAbout: PROC [sideCare: SideCare, side: Side] RETURNS [BOOL] ~ INLINE {RETURN [SELECT sideCare FROM neither => FALSE, left => side=left, right => side=right, both => TRUE, ENDCASE => ERROR]}; Image: PROC [pc: PairColl, coll: Collection, dir: Direction _ leftToRight] RETURNS [UWColl] <> ~ INLINE {RETURN pc.class.Image[pc, coll, dir]}; Mapping: PROC [pc: PairColl, v: Value, dir: Direction _ leftToRight] RETURNS [UWColl] <> ~ INLINE {RETURN pc.class.Image[pc, Colls.CreateSingleton[v, pc.Spaces[][Source[dir]]], dir]}; Enumerate: PROC [pc: PairColl, Consume: PROC [Pair], bkwd: BOOL _ FALSE]; MaybePair: TYPE ~ RECORD [found: BOOL, pair: Pair]; noMaybePair: READONLY MaybePair -- = [FALSE, noPair] --; ParallelFind: TYPE ~ RECORD [found: BOOL, a, b: MaybePair]; Tester: TYPE ~ PROC [pair: Pair] RETURNS [pass: BOOL _ FALSE]; Scan: PROC [pc: PairColl, Test: Tester, bkwd: BOOL _ FALSE] RETURNS [MaybePair] ~ INLINE {RETURN pc.class.Scan[pc, Test, bkwd]}; EnumerateImage: PROC [pc: PairColl, coll: Collection, Consume: PROC [Value], dir: Direction _ leftToRight, bkwd: BOOL _ FALSE]; EnumerateMapping: PROC [pc: PairColl, v: Value, Consume: PROC [Value], dir: Direction _ leftToRight, bkwd: BOOL _ FALSE] ~ INLINE {EnumerateImage[pc, Colls.CreateSingleton[v, pc.Spaces[][Source[dir]]], Consume, dir, bkwd]}; EnumerateHalfRestriction: PROC [pc: PairColl, coll: Collection, Consume: PROC [Pair], side: Side _ left, bkwd: BOOL _ FALSE]; <> ScanImage: PROC [pc: PairColl, coll: Collection, Test: Colls.Tester, dir: Direction _ leftToRight, bkwd: BOOL _ FALSE] RETURNS [MaybePair]; ScanMapping: PROC [pc: PairColl, v: Value, Test: Colls.Tester, dir: Direction _ leftToRight, bkwd: BOOL _ FALSE] RETURNS [MaybePair] ~ INLINE {RETURN ScanImage[pc, Colls.CreateSingleton[v, pc.Spaces[][Source[dir]]], Test, dir, bkwd]}; ScanHalfRestriction: PROC [pc: PairColl, coll: Collection, Test: Tester, side: Side _ left, bkwd: BOOL _ FALSE] RETURNS [MaybePair] ~ INLINE {RETURN pc.class.ScanHalfRestriction[pc, side, coll, Test, bkwd]}; ParallelTester: TYPE ~ PROC [a, b: MaybePair] RETURNS [pass: BOOL _ FALSE]; ParallelScan: PROC [a, b: PairColl, Test: ParallelTester, bkwd: BOOL _ FALSE] RETURNS [ParallelFind] ~ INLINE {RETURN ParallelScanHalfRestriction[a, b, passAll, Test, left, bkwd]}; ParallelScanHalfRestriction: PROC [a, b: PairColl, coll: Collection, Test: ParallelTester, side: Side _ left, bkwd: BOOL _ FALSE] RETURNS [ParallelFind]; First: PROC [pc: PairColl] RETURNS [MaybePair] ~ INLINE {RETURN pc.class.Extremum[pc, FALSE, FALSE]}; Last: PROC [pc: PairColl] RETURNS [MaybePair] ~ INLINE {RETURN pc.class.Extremum[pc, TRUE, FALSE]}; Pop: PROC [pc: PairColl, bkwd: BOOL _ FALSE] RETURNS [MaybePair] ~ INLINE {RETURN pc.class.Extremum[pc, bkwd, TRUE]}; Extremum: PROC [pc: PairColl, bkwd, remove: BOOL] RETURNS [MaybePair] ~ INLINE {RETURN pc.class.Extremum[pc, bkwd, remove]}; Next: PROC [pc: PairColl, pair: Pair] RETURNS [MaybePair] ~ INLINE {RETURN [pc.class.Get3[pc, pair].next]}; Prev: PROC [pc: PairColl, pair: Pair] RETURNS [MaybePair] ~ INLINE {RETURN [pc.class.Get3[pc, pair].prev]}; Get3: PROC [pc: PairColl, pair: Pair] RETURNS [prev, same, next: MaybePair] ~ INLINE {RETURN pc.class.Get3[pc, pair]}; Size: PROC [pc: PairColl, limit: LNAT _ LNAT.LAST] RETURNS [LNAT] ~ INLINE {RETURN [pc.class.Size[pc, limit]]}; Empty: PROC [pc: PairColl] RETURNS [BOOL] ~ INLINE {RETURN [pc.class.Size[pc, 1]=0]}; ImageSize: PROC [pc: PairColl, coll: Collection, dir: Direction _ leftToRight, limit: LNAT _ LNAT.LAST] RETURNS [LNAT] ~ INLINE {RETURN [pc.class.ImageSize[pc, coll, dir, limit]]}; MappingSize: PROC [pc: PairColl, v: Value, dir: Direction _ leftToRight, limit: LNAT _ LNAT.LAST] RETURNS [LNAT] ~ INLINE {RETURN [pc.class.ImageSize[pc, Colls.CreateSingleton[v, pc.Spaces[][Source[dir]]], dir, limit]]}; MutabilityOf: PROC [pc: PairColl] RETURNS [Mutability] ~ INLINE {RETURN [pc.class.mutability]}; Copy: PROC [pc: PairColl] RETURNS [VarPairColl] ~ INLINE {RETURN pc.class.Copy[pc]}; Insulate: PROC [pc: PairColl] RETURNS [UWPairColl] ~ INLINE {RETURN pc.class.Insulate[pc]}; ValueOf: PROC [pc: PairColl] RETURNS [ConstPairColl] ~ INLINE {RETURN pc.class.ValueOf[pc]}; Freeze: PROC [pc: PairColl] RETURNS [const: ConstPairColl] ~ INLINE {RETURN pc.class.Freeze[pc]}; Thaw: PROC [pc: PairColl] ~ INLINE {pc.class.Thaw[pc]}; Where: TYPE ~ RECORD [SELECT kind: WhereKind FROM any => [], end => [end: End], rel => [pair: Pair, reln: WhereReln], ENDCASE _ any[]]; News: TYPE ~ {same, different, new}; NewsPair: TYPE ~ PACKED ARRAY Direction OF News; NewsSetPair: TYPE ~ ARRAY Direction OF PACKED ARRAY News OF BOOL; <> IfNews: TYPE ~ PACKED ARRAY --news=new--BOOL OF --add:--BOOL; IfNewsPair: TYPE ~ ARRAY Direction OF IfNews; <> alwaysAdd: IfNewsPair ~ ALL[ALL[TRUE]]; addIfNew: IfNewsPair ~ ALL[[FALSE, TRUE]]; addIfOld: IfNewsPair ~ ALL[[TRUE, FALSE]]; AddPair: PROC [pc: PairColl, pair: Pair, if: IfNewsPair _ alwaysAdd, where: Where _ []] RETURNS [news: NewsPair]; AddNewPair: PROC [pc: PairColl, pair: Pair, where: Where _ []]; <> AddColl: PROC [pc, other: PairColl, if: IfNewsPair _ alwaysAdd, where: Where _ []] RETURNS [some: NewsSetPair] <> ~ INLINE {RETURN pc.class.AddColl[pc, other, if, where]}; AddNewColl: PROC [pc, other: PairColl, where: Where _ []]; <> RemPair: PROC [pc: PairColl, pair: Pair, style: RemoveStyle _ any] RETURNS [hadMapping: BoolPair] <> ~ INLINE {RETURN [pc.class.RemColl[pc, CreateSingleton[pair, pc.Spaces[]], style].hadAll]}; RemColl: PROC [pc, other: PairColl, style: RemoveStyle _ any] RETURNS [hadSome, hadAll: BoolPair] <> ~ INLINE {RETURN pc.class.RemColl[pc, other, style]}; Delete: PROC [pc: PairColl, val: Value, side: Side _ left, style: RemoveStyle _ all] RETURNS [hadSome: BOOL] <> ~ INLINE {RETURN [pc.class.DeleteColl[pc, Colls.CreateSingleton[val, pc.Spaces[][side]], side, style].hadSome]}; DeleteColl: PROC [pc: PairColl, coll: Collection, side: Side _ left, style: RemoveStyle _ all] RETURNS [hadSome, hadAll: BOOL] ~ INLINE {RETURN pc.class.DeleteColl[pc, coll, side, style]}; Spaces: PROC [pc: PairColl] RETURNS [SpacePair] <> ~ INLINE {RETURN pc.class.Spaces[pc]}; CollectionOn: PROC [pc: PairColl, side: Side] RETURNS [UWColl] <> ~ INLINE {RETURN [pc.class.CollectionOn[pc, side]]}; CurSetOn: PROC [pc: PairColl, side: Side] RETURNS [ConstSet] <> ~ INLINE {RETURN [[pc.class.CurSetOn[pc, side]]]}; Functional: PROC [pc: PairColl] RETURNS [BoolPair] < pc can't have two pairs with equivalent left Values and non-equivalent right Values.>> ~ INLINE {RETURN [pc.class.functional]}; MayDuplicate: PROC [pc: PairColl] RETURNS [BOOL] <> ~ INLINE {RETURN [pc.class.mayDuplicate]}; refPairColls: READONLY Space; Equal: PROC [a, b: PairColl, bounds: CollPair _ [passAll, passAll]] RETURNS [BOOL]; <<>> Hash: PROC [pc: PairColl, bounds: CollPair _ [passAll, passAll]] RETURNS [CARDINAL]; Compare: PROC [a, b: PairColl, bounds: CollPair _ [passAll, passAll]] RETURNS [Basics.Comparison]; <> VarPairColl: TYPE ~ RECORD [PairColl] --a variable PairColl--; IsVar: PROC [pc: PairColl] RETURNS [BOOL] ~ INLINE {RETURN [pc.class.mutability=variable]}; AsVar: PROC [pc: PairColl] RETURNS [VarPairColl] ~ INLINE {IF pc#nilPairColl AND pc.class.mutability#variable THEN Complain[pc, notVariable]; RETURN [[pc]]}; UWPairColl: TYPE ~ RECORD [PairColl] --an unwritable PairColl--; IsUW: PROC [pc: PairColl] RETURNS [BOOL] ~ INLINE {RETURN [pc.class.mutability#variable]}; AsUW: PROC [pc: PairColl] RETURNS [UWPairColl] ~ INLINE {IF pc#nilPairColl AND pc.class.mutability=variable THEN Complain[pc, writeable]; RETURN [[pc]]}; ConstPairColl: TYPE ~ RECORD [UWPairColl] --a constant PairColl--; IsConst: PROC [pc: PairColl] RETURNS [BOOL] ~ INLINE {RETURN [pc.class.mutability=constant]}; AsConst: PROC [pc: PairColl] RETURNS [ConstPairColl] ~ INLINE {IF pc#nilPairColl AND pc.class.mutability#constant THEN Complain[pc, notConstant]; RETURN [[[pc]]]}; Relation: TYPE ~ PairColl --a binary relation: a non-duplicating pair collection--; VarRelation: TYPE ~ VarPairColl; ConstRelation: TYPE ~ ConstPairColl; IsRelation: PROC [pc: PairColl] RETURNS [BOOL] ~ INLINE {RETURN [NOT pc.class.mayDuplicate]}; Function: TYPE ~ PairColl --a non-duplicating pair collection that doesn't have two pairs with equal left sides--; VarFunction: TYPE ~ VarPairColl; UWFunction: TYPE ~ UWPairColl; ConstFunction: TYPE ~ ConstPairColl; IsFunction: PROC [pc: PairColl] RETURNS [BOOL] ~ INLINE {RETURN [pc.class.functional[leftToRight] AND NOT pc.class.mayDuplicate]}; InvFunction: TYPE ~ PairColl --a non-duplicating pair collection that doesn't have two pairs with equal right sides--; VarInvFunction: TYPE ~ VarPairColl; UWInvFunction: TYPE ~ UWPairColl; ConstInvFunction: TYPE ~ ConstPairColl; IsInvFunction: PROC [pc: PairColl] RETURNS [BOOL] ~ INLINE {RETURN [pc.class.functional[rightToLeft] AND NOT pc.class.mayDuplicate]}; OneToOne: TYPE ~ PairColl --a one-to-one relation--; VarOneToOne: TYPE ~ VarPairColl; ConstOneToOne: TYPE ~ ConstPairColl; IsOneToOne: PROC [pc: PairColl] RETURNS [BOOL] ~ INLINE {RETURN [pc.class.functional=ALL[TRUE] AND NOT pc.class.mayDuplicate]}; Store: PROC [pc: Function, pair: Pair] RETURNS [new: BOOL] ~ INLINE {RETURN [pc.AddPair[pair][leftToRight]=new]}; Replace: PROC [pc: Function, pair: Pair] RETURNS [old: BOOL] ~ INLINE {RETURN [pc.AddPair[pair, [[TRUE, FALSE], ALL[TRUE]]][leftToRight]#new]}; Insert: PROC [pc: Function, pair: Pair] RETURNS [new: BOOL] ~ INLINE {RETURN [pc.AddPair[pair, [[FALSE, TRUE], ALL[TRUE]]][leftToRight]=new]}; Inserted: PROC [pc: Function, pair: Pair] RETURNS [Value] ~ INLINE { IF NOT pc.Insert[pair] THEN Error[notNew, LIST[NEW [Function _ pc], NEW [Pair _ pair]]]; RETURN [pair[right]]}; notNew: READONLY ROPE; Apply: PROC [pc: PairColl, v: Value, dir: Direction _ leftToRight] RETURNS [MaybeValue] <> ~ INLINE {RETURN pc.class.Apply[pc, v, dir]}; Bag: TYPE ~ Function --where range is REF INT; this is a.k.a. a multiset; it is a function from an item to the number of occurrences of that item--; IsIntFn: PROC [pc: PairColl, dir: Direction _ leftToRight] RETURNS [BOOL] ~ INLINE {RETURN [pc.QuaIntFn.found]}; AsIntFn: PROC [pc: PairColl, dir: Direction _ leftToRight] RETURNS [REF ANY] ~ INLINE {RETURN [QuaIntFn[pc].val]}; QuaIntFn: PROC [pc: PairColl, dir: Direction _ leftToRight] RETURNS [MaybeValue] ~ INLINE {RETURN pc.class.QuaIntFn[pc, dir]}; <> empty, id: READONLY ConstPairColl; CreateSingleton: PROC [elt: Pair, spaces: SpacePair] RETURNS [ConstPairColl] ~ INLINE {RETURN [[[[GetSingletonClass[spaces], NEW [Pair _ elt]]]]]}; GetSingletonClass: PROC [spaces: SpacePair] RETURNS [PairCollClass]; NCreateSingleton: PROC [elt: Pair, spaces: SpacePair] RETURNS [ConstPairColl]; CreateIDSubset: PROC [Collection] RETURNS [PairColl]; CreateProduct: PROC [CollPair] RETURNS [PairColl]; CreateFromList: PROC [vals: LOP, functional: BoolPair _ [FALSE, FALSE], spaces: SpacePair _ [refs, refs], mayDuplicate: BOOL _ FALSE] RETURNS [ConstPairColl]; HashFn: TYPE ~ VarFunction; CreateHashReln: PROC [spaces: SpacePair _ [refs, refs], functional: BoolPair _ [FALSE, FALSE], mappable: BoolPair _ [TRUE, TRUE]] RETURNS [VarPairColl]; <<(functional[dir] OR mappable[dir]) tells whether the result can Image in direction dir.>> CreateHashOTO: PROC [spaces: SpacePair _ [refs, refs]] RETURNS [VarOneToOne] ~ INLINE {RETURN CreateHashReln[spaces, ALL[TRUE]]}; CreateHashFn: PROC [spaces: SpacePair _ [refs, refs], invable: BOOL _ TRUE] RETURNS [HashFn] ~ INLINE {RETURN CreateHashReln[spaces, [TRUE, FALSE], [TRUE, invable]]}; CreateHashTable: PROC [right: Space _ refs, invable: BOOL _ TRUE] RETURNS [HashFn] ~ INLINE {RETURN CreateHashReln[[refs, right], [TRUE, FALSE], [TRUE, invable]]}; CreateHashDictionary: PROC [case: BOOL _ TRUE, right: Space _ refs, invable: BOOL _ TRUE] RETURNS [HashFn] ~ INLINE {RETURN CreateHashReln[[ropes[case], right], [TRUE, FALSE], [TRUE, invable]]}; CreateHashCopy: PROC [pc: PairColl, spaces: SpacePair _ [NIL, NIL], mappable: BoolPair _ [FALSE, FALSE]] RETURNS [HashFn]; <> RedBlackReln: TYPE ~ VarRelation; CreateRedBlackReln: PROC [spaces: SpacePair _ [refs, refs], functional: BoolPair _ [FALSE, FALSE], mappable: BoolPair _ [TRUE, TRUE]] RETURNS [RedBlackReln]; CreateRedBlackCopy: PROC [pc: PairColl, spaces: SpacePair _ [NIL, NIL], mappable: BoolPair _ [FALSE, FALSE]] RETURNS [RedBlackReln]; <> Union: PROC [a, b: PairColl] RETURNS [PairColl]; DisjointUnion: PROC [a, b: Relation] RETURNS [Relation]; <> Intersection: PROC [PairColl, PairColl] RETURNS [PairColl]; Difference: PROC [PairColl, PairColl] RETURNS [PairColl]; SymmetricDifference: PROC [a, b: PairColl] RETURNS [c: PairColl]; Negate: PROC [PairColl] RETURNS [PairColl]; Compose: PROC [pcs: ARRAY Side OF PairColl, restricts: ARRAY Side OF BOOL _ [TRUE, TRUE]] RETURNS [PairColl]; <> Invert: PROC [PairColl] RETURNS [PairColl]; FnFromProc: PROC [Apply: PROC [data: REF ANY, v: Value] RETURNS [mv: MaybeValue], spaces: SpacePair _ [refs, refs], data: REF ANY _ NIL, constant, oneToOne: BOOL _ FALSE, ScanInverse: PROC [data: REF ANY, v: Value, Test: Tester] RETURNS [MaybePair] _ NIL] RETURNS [Function]; CreateCountingBag: PROC [coll: Collection] RETURNS [Bag] ~ INLINE {RETURN [[countingBagClass, NEW [Collection _ coll]]]}; countingBagClass: READONLY PairCollClass; <> PairCollClass: TYPE ~ REF PairCollClassPrivate; PairCollClassPrivate: TYPE ~ MONITORED RECORD [ Primitive: PROC [pc: PairColl, op: ATOM, args: ArgList _ NIL] RETURNS [PrimitiveAnswer] _ NIL, Widen: PROC [pc: PairColl] RETURNS [Collection--of REF Pair--] _ NIL, HasPair: PROC [pc: PairColl, pair: Pair] RETURNS [BOOL] _ NIL, Image: PROC [pc: PairColl, coll: Collection, dir: Direction] RETURNS [UWColl] _ NIL, Apply: PROC [pc: PairColl, v: Value, dir: Direction] RETURNS [MaybeValue] _ NIL, Scan: PROC [pc: PairColl, Test: Tester, bkwd: BOOL] RETURNS [MaybePair] _ NIL, ScanHalfRestriction: PROC [pc: PairColl, side: Side, coll: Collection, Test: Tester, bkwd: BOOL] RETURNS [MaybePair] _ NIL, Extremum: PROC [pc: PairColl, bkwd, remove: BOOL] RETURNS [MaybePair] _ NIL, Get3: PROC [pc: PairColl, pair: Pair] RETURNS [prev, same, next: MaybePair] _ NIL, Size: PROC [pc: PairColl, limit: LNAT] RETURNS [LNAT] _ NIL, ImageSize: PROC [pc: PairColl, coll: Collection, dir: Direction, limit: LNAT] RETURNS [LNAT] _ NIL, Copy: PROC [pc: PairColl] RETURNS [VarPairColl] _ NIL, Insulate: PROC [pc: PairColl] RETURNS [UWPairColl] _ NIL, ValueOf: PROC [pc: PairColl] RETURNS [ConstPairColl] _ NIL, Freeze: PROC [pc: PairColl] RETURNS [const: ConstPairColl] _ NIL, Thaw: PROC [pc: PairColl] _ NIL, CollectionOn: PROC [pc: PairColl, side: Side] RETURNS [UWColl] _ NIL, CurSetOn: PROC [pc: PairColl, side: Side] RETURNS [ConstSet] _ NIL, AddColl: PROC [pc, other: PairColl, if: IfNewsPair, where: Where] RETURNS [some: NewsSetPair] _ NIL, RemColl: PROC [pc, other: PairColl, style: RemoveStyle] RETURNS [hadSome, hadAll: BoolPair] _ NIL, DeleteColl: PROC [pc: PairColl, coll: Collection, side: Side, style: RemoveStyle] RETURNS [hadSome, hadAll: BOOL] _ NIL, QuaIntFn: PROC [pc: PairColl, dir: Direction] RETURNS [MaybeValue] _ NIL, Spaces: PROC [pc: PairColl] RETURNS [SpacePair] _ NIL, OrderingOf: PROC [pc: PairColl] RETURNS [Ordering] _ NIL, functional: BoolPair _ [FALSE, FALSE], mayDuplicate: BOOL _ TRUE, orderStyle: OrderStyle _ none, mutability: Mutability _ variable, other: Atom.PropList _ NIL, --the canonical expansion slot data: Value _ NIL ]; <> CreateClass: PROC [cp: PairCollClassPrivate, bkwdable: BB _ [TRUE, FALSE], dirable: BoolPair _ [TRUE, FALSE]] RETURNS [PairCollClass]; <> DefaultWiden: PROC [pc: PairColl] RETURNS [Collection--of REF Pair--]; DefaultImage: PROC [pc: PairColl, coll: Collection, dir: Direction] RETURNS [UWColl]; DefaultApply: PROC [pc: PairColl, v: Value, dir: Direction] RETURNS [MaybeValue]; DefaultScan: PROC [pc: PairColl, Test: Tester, bkwd: BOOL] RETURNS [MaybePair]; DefaultScanHalfRestriction: PROC [pc: PairColl, side: Side, coll: Collection, Test: Tester, bkwd: BOOL] RETURNS [MaybePair]; DefaultExtremum: PROC [pc: PairColl, bkwd, remove: BOOL] RETURNS [MaybePair]; DefaultGet3: PROC [pc: PairColl, pair: Pair] RETURNS [prev, same, next: MaybePair]; DefaultImageSize: PROC [pc: PairColl, coll: Collection, dir: Direction, limit: LNAT] RETURNS [LNAT]; DefaultCollectionOn: PROC [pc: PairColl, side: Side] RETURNS [UWColl]; DefaultCurSetOn: PROC [pc: PairColl, side: Side] RETURNS [ConstSet]; DefaultInsulate: PROC [pc: PairColl] RETURNS [UWPairColl]; DefaultDeleteColl: PROC [pc: PairColl, coll: Collection, side: Side, style: RemoveStyle] RETURNS [hadSome, hadAll: BOOL]; DefaultQuaIntFn: PROC [pc: PairColl, dir: Direction] RETURNS [MaybeValue]; DefaultSpaces: PROC [pc: PairColl] RETURNS [SpacePair]; DefaultOrderingOf: PROC [pc: PairColl] RETURNS [Ordering]; IsDefaultOrdering: PROC [Ordering] RETURNS [BOOL]; GetSide: PROC [args: ArgList, i: NAT, default: Side _ left] RETURNS [Side]; FromSide: PROC [Side] RETURNS [ATOM]; UpdatePairCollClassOther: PROC [class: PairCollClass, Update: PROC [Atom.PropList] RETURNS [Atom.PropList]]; <> InvertSideCare: ARRAY SideCare OF SideCare ~ [neither: neither, left: right, right: left, both: both]; SpacePair: TYPE ~ ARRAY Side OF Space; LOP: TYPE ~ LIST OF Pair; CollPair: TYPE ~ ARRAY Side OF Collection; ConsPair: PROC [first: Side, v1, v2: Value] RETURNS [pair: Pair] ~ INLINE {pair[first] _ v1; pair[OtherSide[first]] _ v2}; Complain: PROC [pc: PairColl, msg: ROPE, args: LOV _ NIL] ~ INLINE {Error[msg, CONS[NEW [PairColl _ pc], args]]}; P: PROC [mp: MaybePair] RETURNS [Pair] ~ INLINE {IF mp.found THEN RETURN [mp.pair] ELSE Error[notFound, NIL]}; DP: PROC [mp: MaybePair, ifNotFound: Pair _ [NIL, NIL]] RETURNS [Pair] ~ INLINE {RETURN [IF mp.found THEN mp.pair ELSE ifNotFound]}; WidenSpacePair: PROC [sp: SpacePair] RETURNS [s: Space]; <> IsPairSpace: PROC [s: Space] RETURNS [BOOL]; <> NarrowSpace: PROC [s: Space] RETURNS [sp: SpacePair]; <> WidenOrdering: PROC [o: Ordering] RETURNS [wo: Colls.Ordering]; <> NarrowOrdering: PROC [wo: Colls.Ordering] RETURNS [o: Ordering]; <> InvertPair: PROC [x: Pair] RETURNS [Pair] <> ~ INLINE {RETURN [[x[right], x[left]]]}; InvertBoolPair: PROC [x: BoolPair] RETURNS [BoolPair] ~ INLINE {RETURN [[x[rightToLeft], x[leftToRight]]]}; InvertMaybe: PROC [mp: MaybePair] RETURNS [MaybePair] ~ INLINE {RETURN [[mp.found, InvertPair[mp.pair]]]}; InvertNewsPair: PROC [x: NewsPair] RETURNS [NewsPair] ~ INLINE {RETURN [[x[rightToLeft], x[leftToRight]]]}; InvertNewsSetPair: PROC [x: NewsSetPair] RETURNS [NewsSetPair] ~ INLINE {RETURN [[x[rightToLeft], x[leftToRight]]]}; InvertIfNewsPair: PROC [x: IfNewsPair] RETURNS [IfNewsPair] ~ INLINE {RETURN [[x[rightToLeft], x[leftToRight]]]}; InvertSpacePair: PROC [x: SpacePair] RETURNS [SpacePair] ~ INLINE {RETURN [[x[right], x[left]]]}; InvertWhere: PROC [x: Where] RETURNS [Where] ~ INLINE {WITH x SELECT FROM y: any Where => RETURN [y]; y: end Where => RETURN [y]; y: rel Where => RETURN [[rel[InvertPair[y.pair], y.reln]]]; ENDCASE => ERROR}; InvertOrdering: PROC [o: Ordering] RETURNS [io: Ordering]; <> ReverseOrdering: PROC [o: Ordering] RETURNS [ro: Ordering]; <> }.