--File: IPSimpleTree.mesa
Last Edited by: CSChow, February 2, 1985 2:51:50 am PST
DIRECTORY
Rope,
SymTab;
IPSimpleTree: CEDAR DEFINITIONS = BEGIN
--Intro: This is an extremely simple minded implementation of tree.
-- Nodes are records with (i) own name, (ii) areaEstimate, (iii) name of parent,
-- (iv) names of children.
-- The 'any' field is used to hold a number of things, look at the Impl.
Ref: TYPE = REF Rep;
Rep: TYPE = RECORD[
tab: SymTab.Ref,
initialized: BOOLFALSE,
root: Rope.ROPENIL
];
Nodes: TYPE = LIST OF Node;
Node: TYPE = REF NodeRep;
NodeRep: TYPE = RECORD[
name: Rope.ROPE,
areaEstimate: INT ← 0,
any: REFNIL,
parent: Rope.ROPENIL,
children: LIST OF Rope.ROPENIL];
Create: PROC [] RETURNS [Ref];
--(A) Tree Constructors:
AddNode: PROC[st: Ref, ndName, parent: Rope.ROPE, children: LIST OF Rope.ROPE, areaEst: INT ← 0, any: REFNIL];
RemoveNode: PROC[st: Ref, ndName: Rope.ROPE] RETURNS [done: BOOL];
-- (B) Tree Queries:
GetRoot: PROC[st: Ref] RETURNS [Node];
GetLeaves: PROC[st: Ref] RETURNS [count: NAT, leaves: Nodes];
GetNode: PROC[st: Ref, nodeName: Rope.ROPE, raiseError: BOOLTRUE] RETURNS [Node];
-- IF (nodeName is not a namraise e of node) AND raiseError
-- THEN raise ! IP.Error[missingRegistration, "<nodeName> is not a node"]
GetChildren: PROC[st: Ref, node: Node] RETURNS [Nodes];
GetParent: PROC[st: Ref, node: Node] RETURNS [Node];
END.