TiogaPathOrder.mesa; Written by Paxton, July 1983
edited by Paxton, July 18, 1983 2:26 pm
DIRECTORY
TiogaNode;
TiogaPathOrder: CEDAR DEFINITIONS = BEGIN
Order: TYPE = { same, before, after, disjoint };
Ref: TYPE = TiogaNode.Ref;
Path: TYPE = TiogaNode.Path;
Compare: PROC [path1, path2: Path] RETURNS [order: Order];
determines relative order in tree of the nodes at the ends of the paths
returns "same" if node1 = node2
returns "before" if node1 comes before node2
returns "after" if node1 comes after node2
returns "disjoint" if nodes are not from the same tree
If you're going to do several comparisons, use the following operations.
FullPath: TYPE = REF FullPathArray;
FullPathArray: TYPE = RECORD [
next: FullPath, -- for free list
length: NAT ← 0,
nodes: SEQUENCE maxLength: NAT OF TiogaNode.Ref
];
MakeFullPath: PROC [p: Path] RETURNS [fp: FullPath];
CompareFullPaths: PUBLIC PROC [fp1, fp2: FullPath] RETURNS [order: Order];
FreeFullPath: PROC [fp: FullPath];
Puts the path on a free list. Don't free more than once!
END.