FitStateUtilsImpl.mesa
Maureen Stone July 2, 1984 2:18:13 pm PDT
DIRECTORY
FitStateUtils,
FitBasic USING [Handle, SampleHandle, LinkHandle, SListHandle, TrajHandle, Contour];
FitStateUtilsImpl: CEDAR PROGRAM EXPORTS FitStateUtils =
BEGIN OPEN FitBasic, FitStateUtils;
SampleProc: TYPE = PROC[s: SampleHandle] RETURNS [done: BOOLEAN];
LinkProc: TYPE =PROC[l: LinkHandle] RETURNS [done: BOOLEAN];
SListProc: TYPE =PROC[slist: SListHandle] RETURNS [done: BOOLEAN];
TrajProc: TYPE =PROC[traj: TrajHandle] RETURNS [done: BOOLEAN];
SLists have a header and samples are circularly linked
ForAllSamples: PUBLIC PROC [slist: SListHandle, do: SampleProc] = {
IF slist#NIL AND (slist.first=NIL OR slist.last=NIL) THEN
FOR s: SampleHandle ← slist.header.next, s.next WHILE s#slist.header DO
IF do[s] THEN EXIT;
ENDLOOP;
IF slist#NIL AND slist.first#NIL AND slist.last#NIL THEN
FOR s: SampleHandle ← slist.first, s.next UNTIL s=slist.last.next DO
IF s#slist.header THEN IF do[s] THEN EXIT;
ENDLOOP;
};
Links do not have headers
ForAllLinks: PUBLIC PROC [traj: TrajHandle, do: LinkProc] = {
FOR l: LinkHandle ← traj.links, l.next UNTIL l=NIL DO
IF do[l] THEN EXIT;
ENDLOOP;
};
ForAllSLists: PUBLIC PROC [handle: Handle, do: SListProc] = { --all samples in handle
IF handle.slist=NIL THEN ForAllOtherSLists[handle,do]
ELSE IF ~do[handle.slist] THEN ForAllOtherSLists[handle,do];
};
ForAllTrajs: PUBLIC PROC [handle: Handle, do: TrajProc] = { --all links in handle
IF handle.traj=NIL THEN ForAllOtherTrajs[handle,do]
ELSE IF ~do[handle.traj] THEN ForAllOtherTrajs[handle,do];
};
ForAllOtherSLists: PUBLIC PROC [handle: Handle, do: SListProc] = {
all samples in handle.otherContours
IF handle.otherContours#NIL THEN
FOR ts: LIST OF Contour ← handle.otherContours, ts.rest UNTIL ts=NIL DO
IF do[ts.first.slist] THEN EXIT;
ENDLOOP;
};
ForAllOtherTrajs: PUBLIC PROC [handle: Handle, do: TrajProc] = { --all links in handle.otherContours
IF handle.otherContours#NIL THEN
FOR ts: LIST OF Contour ← handle.otherContours, ts.rest UNTIL ts=NIL DO
IF do[ts.first.traj] THEN EXIT;
ENDLOOP;
};
END.