Created
May 26, 2016 18:57
-
-
Save kpmy/b98d9ee2a04fa73f0746cc4296bce544 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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