Skip to content

Instantly share code, notes, and snippets.

@kpmy
Created May 26, 2016 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kpmy/b98d9ee2a04fa73f0746cc4296bce544 to your computer and use it in GitHub Desktop.
Save kpmy/b98d9ee2a04fa73f0746cc4296bce544 to your computer and use it in GitHub Desktop.
TYPE
ObjList* = LIMITED RECORD
list: ListsLinear.List;
END;
VAR
objList-: ObjList;
PROCEDURE (VAR l: ObjList) ForEach* (s: Service; VAR action: Action), NEW;
VAR i: INTEGER; x: ANYPTR;
BEGIN
i:=0; action.stop:=FALSE;
WHILE (i<l.list.len) & ~action.stop DO
x:=l.list.GetItem(i);
ASSERT(x#NIL, 40);
WITH x: Obj DO
action.Do(s, x);
ELSE HALT(100) END;
INC(i);
END;
END ForEach;
PROCEDURE (VAR l: ObjList) This* (idx: INTEGER): Obj, NEW;
VAR x: ANYPTR; res: Obj;
BEGIN
ASSERT(idx<l.list.len, 20); ASSERT(idx>=0, 21);
x:=l.list.GetItem(idx);
IF x#NIL THEN res:=x(Obj) END;
RETURN res
END This;
PROCEDURE (VAR l: ObjList) Length* (): INTEGER, NEW;
BEGIN
RETURN l.list.len
END Length;
PROCEDURE (VAR l: ObjList) Add(obj: Obj), NEW;
BEGIN
l.list.SetLength(l.list.len+1);
l.list.SetItem(l.list.len-1, obj);
END Add;
IMPORT ypkDetails
BEGIN
IF (h.next < ypkDetails.objList.Length()) THEN
o:=ypkDetails.objList.This(h.next);
END;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment