mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-12-22 14:52:39 +03:00
cca1343075
git-svn-id: svn://kolibrios.org@6755 a494cfbc-eb01-0410-851d-a64ba20cac60
57 lines
842 B
Plaintext
57 lines
842 B
Plaintext
MODULE vector_ex;
|
|
|
|
IMPORT C := ConsoleLib, Out, V := Vector;
|
|
|
|
|
|
TYPE
|
|
|
|
STRING = ARRAY 240 OF CHAR;
|
|
|
|
Item = POINTER TO RECORD (V.ANYREC) inf: STRING END;
|
|
|
|
|
|
PROCEDURE add(v: V.VECTOR; s: STRING);
|
|
VAR item: Item;
|
|
BEGIN
|
|
NEW(item);
|
|
item.inf := s;
|
|
V.push(v, item)
|
|
END add;
|
|
|
|
|
|
PROCEDURE print(v: V.VECTOR; first, last: INTEGER);
|
|
VAR any : V.ANYPTR;
|
|
i : INTEGER;
|
|
BEGIN
|
|
i := first;
|
|
WHILE i <= last DO
|
|
any := V.get(v, i);
|
|
Out.String(any(Item).inf);
|
|
Out.Ln;
|
|
INC(i)
|
|
END;
|
|
END print;
|
|
|
|
|
|
PROCEDURE main;
|
|
VAR v: V.VECTOR;
|
|
BEGIN
|
|
C.open(-1, -1, -1, -1, "vector");
|
|
|
|
v := V.create(1024);
|
|
|
|
add(v, "abc");
|
|
add(v, "def");
|
|
add(v, "123");
|
|
add(v, "qwerty");
|
|
add(v, "hello");
|
|
|
|
print(v, 0, V.count(v) - 1);
|
|
|
|
C.exit(FALSE)
|
|
END main;
|
|
|
|
|
|
BEGIN
|
|
main
|
|
END vector_ex. |