<<>> <> <> <> <> DIRECTORY FitStateUtils, FitBasic USING [Handle, SampleHandle, LinkHandle, SListHandle, TrajHandle, Contour]; FitStateUtilsImpl: CEDAR PROGRAM EXPORTS FitStateUtils = BEGIN OPEN FitBasic, FitStateUtils; <> <> <> <> <<>> <> 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; }; <> AtEnd: PUBLIC SIGNAL = CODE; NextSa: PUBLIC PROC [slist: SListHandle, s: SampleHandle, closed: BOOLEAN] RETURNS [SampleHandle] = { ret: SampleHandle ¬ s.next; IF ret=slist.header THEN ret ¬ ret.next; IF s=slist.last AND NOT closed THEN SIGNAL AtEnd; RETURN[ret]; }; PrevSa: PUBLIC PROC [slist: SListHandle, s: SampleHandle, closed: BOOLEAN] RETURNS [SampleHandle] = { ret: SampleHandle ¬ s.prev; IF ret=slist.header THEN ret ¬ ret.prev; IF s=slist.first AND NOT closed THEN SIGNAL AtEnd; RETURN[ret]; }; <<>> <> 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] = { <> 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.