InstanceTable.mesa
Copyright Ó 1987 by Xerox Corporation. All rights reversed.
From Intervals, created by Bertrand Serlet, November 16, 1985 7:22:05 pm PST
Bertrand Serlet, August 8, 1987 10:05:20 pm PDT
DIRECTORY CD, CDBasics, CoreGeometry;
InstanceTable: CEDAR DEFINITIONS = BEGIN
Value: TYPE = REF;
Rect: TYPE = CD.Rect;
Instance: TYPE = CoreGeometry.Instance;
universe: Rect = CDBasics.universe;
empty: Rect = CDBasics.empty;
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.