DIRECTORY CD, Core, CoreGeometry; SinixIntervals: CEDAR DEFINITIONS = BEGIN Interval: TYPE = RECORD [min, max: INT]; universe: Interval = [FIRST[INT], LAST[INT]]; empty: Interval = [LAST[INT], FIRST[INT]]; Table: TYPE = REF TableRec; TableRec: TYPE = MONITORED RECORD [ range: Interval, -- given at creation time, it retains the range of all intervals. Clients should not change this field. leafBuckets: PRIVATE NAT, -- private field to detect when ReHashing is necessary. data: PRIVATE REF TableData ]; TableData: PRIVATE TYPE = RECORD [c: SEQUENCE hashSize: NAT OF LIST OF IW]; IW: TYPE = RECORD [instance: CoreGeometry.Instance, wire: Core.Wire]; Create: PROC [range: Interval, logHashSize: NAT _ 2] RETURNS [Table]; Insert: PROC [table: Table, instance: CoreGeometry.Instance, wire: Core.Wire]; Enumerate: PROC [table: Table, action: PROC [CoreGeometry.Instance, Core.Wire], interval: Interval _ universe]; DeleteOutside: PROC [table: Table, interval: Interval]; END. ZSinixIntervals.mesa Copyright Σ 1985, 1987 by Xerox Corporation. All rights reversed. Created by Bertrand Serlet, November 16, 1985 7:22:05 pm PST Bertrand Serlet, March 18, 1987 0:34:52 am PST Very much like Intervals, but instanciating the types for the Sinix application yields a 20% win in memory and a factor of N (maybe N=3) in speed. Other small wins (DeleteOutsideRange) should gain even more speed. Record representing the interval [min .. max]. Note the inclusion of bounds. Implementation remark: it is a bad idea to use a sequence of IW instead of a list of IW because it means more memory requirement and slower insertion. Creates a new table with a suggested hash size of 2**logHashSize-1. Adds a new value in the table. The corresponding interval must lie in the creation range, otherwise an ERROR might occur. This operation is monitored. Does NOT check if already member of the table. Enumerates all values of the table that overlap a given range. The interval can be outside the range of the table. This operation is NOT monitored. Applies action to each value until action returns TRUE or no more value. Returns TRUE if some action returns TRUE. Deletes all occurences of instances that do not overlap rect in table. The interval can be outside the range of the table. Table is erased when interval=universe. This operation is monitored. ΚQ– "cedar" style˜codešœ™KšœB™BKšœ9Οk™Kšœ3™3Kšœœ ™ Kšœ2œ™JKšœœœ™)K˜—šž œœ$˜7KšœF™FKšœ3™3Kšœ'™'K™K˜—šœ˜K˜——…—ά ‡