Bagness.mesa
Copyright Ó 1987 by Xerox Corporation. All rights reserved.
Bruce Wagar August 14, 1987 4:26:24 pm PDT
Interface for the bagness data structures and associated routines.
DIRECTORY
CD, Core, CoreGeometry, RefTab;
Bagness: CEDAR DEFINITIONS
= PUBLIC BEGIN
TouchProc: TYPE = CoreGeometry.TouchProc;
Transformation: TYPE = CoreGeometry.Transformation;
Rect: TYPE = CD.Rect;
Bagness Information
A bag is a list of CoreGeometry instances with something in common (e.g., connected).
Instance: TYPE = CoreGeometry.Instance;
Instances: TYPE = CoreGeometry.Instances;
Bag: TYPE = RECORD [
head, tail: Instances,
bbox: Rect
];
Bags: TYPE = LIST OF Bag;
BagList: TYPE = RECORD [
bags: Bags,
bbox: Rect];
Bag Procs
BagKeepProc: TYPE = PROC [bag: Bag] RETURNS [keep: BOOLTRUE];
BagIsNotEmpty: PROC [bag: Bag] RETURNS [BOOL];
Decides if bag is not empty.
BagTouchesInstance: PROC [bag: Bag, instance: Instance, touch: TouchProc] RETURNS [BOOL];
Decides if instance touches an instance of bag.
BagTouchesBag: PROC [bag1, bag2: Bag, touch: TouchProc] RETURNS [BOOL];
Decides if any instance of bag1 touches an instance of bag2.
CreateBag: PROC [] RETURNS [Bag];
Returns a new empty bag.
InsertInstance: PROC [bag: Bag, instance: Instance] RETURNS [Bag];
Inserts instance into bag.
BagAppend: PROC [onto, from: Bag] RETURNS [Bag];
Destructive appending of onto and from.
BagPrune: PROC [bag: Bag, keep: InstKeepProc] RETURNS [Bag];
Deletes all instances from bag which don't satisfy keep. Doesn't update bbox.
TransformBag: PROC [bag: Bag, trans: Transformation] RETURNS [Bag];
Returns a copy of bag with trans applied to each instance. Reverses order of instances.
BagList Procs
InstKeepProc: TYPE = PROC [instance: Instance] RETURNS [keep: BOOLTRUE];
BagCount: PROC [bagList: BagList] RETURNS [NAT];
Returns the number of bags in bagList.
CreateBagList: PROC [] RETURNS [BagList];
Returns a new empty bagList.
InsertBag: PROC [bagList: BagList, bag: Bag] RETURNS [BagList];
Inserts bag into bagList.
TransformBagList: PROC [bagList: BagList, trans: Transformation] RETURNS [BagList];
Returns a copy of bagList with trans applied to every bag.
FuseInstance: PROC [bagList: BagList, instance: Instance, touch: TouchProc] RETURNS [BagList];
Destructive fusion merge of instance into bagList.
FuseBagList: PROC [bagList1, bagList2: BagList, touch: TouchProc] RETURNS [BagList];
Destructive fusion merge of bagList1 and bagList2.
MergeBagList: PROC [bagList1, bagList2: BagList] RETURNS [BagList];
Destructive merge of two disjoint bagLists (no fusion performed). Runs faster when bagList1 is shorter.
PruneInstances: PROC [bagList: BagList, keep: InstKeepProc] RETURNS [BagList];
Deletes all instances from bagList which don't satisfy keep.
InstTab Information
InstTab: TYPE = RefTab.Ref;
Val: TYPE = RefTab.Val;
InstTab Procs
InstTabCreate: PROC [mod: NAT ← 17] RETURNS [InstTab];
Creates new table with suggested initial hash size.
InstTabFetch: PROC [instTab: InstTab, inst: Instance] RETURNS [found: BOOL, val: Val];
Returns TRUE and sends back associated value iff inst is in instTab.
InstTabReplace: PROC [instTab: InstTab, inst: Instance, val: Val ← NIL] RETURNS [BOOL];
Returns TRUE after overwriting old value for existing inst-value pair.
If no previous value for inst, returns FALSE without inserting new pair.
InstTabDelete: PROC [instTab: InstTab, inst: Instance] RETURNS [BOOL];
Deletes inst-value pair associated with given inst.
Returns TRUE if deletion actually occurred, FALSE if no such inst.
InstTabInsert: PROC [instTab: InstTab, inst: Instance, val: Val ← NIL] RETURNS [BOOL];
Returns TRUE after inserted new pair.
If previous value existed for key, returns FALSE without changing value.
END.