PipalInstanceTable.mesa
Copyright Ó 1987, 1988 by Xerox Corporation. All rights reversed.
From Intervals, created by Bertrand Serlet, November 16, 1985 7:22:05 pm PST
Bertrand Serlet, March 5, 1988 5:50:45 pm PST
DIRECTORY PipalCore;
PipalInstanceTable: CEDAR DEFINITIONS = BEGIN
Value: TYPE = REF;
Rect: TYPE = RECORD [x1, y1, x2, y2: INT];
Instance: TYPE = PipalCore.Instance;
maxnum: INT = LAST [INT]/2; --/2: poor man's arithmetic overflow protection
minnum: INT = FIRST [INT]/2;
universe: Rect = [minnum, minnum, maxnum, maxnum];
empty: Rect = [maxnum, maxnum, minnum, minnum];
Table: TYPE = REF TableRec;
TableRec: PRIVATE TYPE = MONITORED RECORD [
range: Rect,   -- given at creation time, it retains the range of all rects. Clients should not change this field.
leafBuckets: NAT, -- private field to detect when ReHashing is necessary.
data: REF TableData
];
TableData: PRIVATE TYPE = RECORD [SEQUENCE size: NAT OF LIST OF InstanceValue];
InstanceValue: PRIVATE TYPE = RECORD [instance: Instance, value: Value];
Create: PROC [range: Rect, logSize: NAT ← 2] RETURNS [Table];
Creates a new table with a suggested hash size of 2**logSize.
Insert: PROC [table: Table, instance: Instance, value: Value];
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.
Enumerate: PROC [table: Table, action: PROC [Instance, Value], rect: Rect ← universe];
Enumerates all values of the table that overlap a given rect.
The interval can be outside the range of the table.
This operation is NOT monitored.
DeleteOutside: PROC [table: Table, rect: Rect ← empty];
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 rect=empty.
This operation is monitored.
END.