mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-12-04 22:32:05 +03:00
65c332bd36
git-svn-id: svn://kolibrios.org@7983 a494cfbc-eb01-0410-851d-a64ba20cac60
59 lines
825 B
Plaintext
59 lines
825 B
Plaintext
(*
|
|
BSD 2-Clause License
|
|
|
|
Copyright (c) 2018-2019, Anton Krotov
|
|
All rights reserved.
|
|
*)
|
|
|
|
MODULE COLLECTIONS;
|
|
|
|
|
|
TYPE
|
|
|
|
ITEM* = POINTER TO RECORD
|
|
|
|
link: ITEM
|
|
|
|
END;
|
|
|
|
COLLECTION* = POINTER TO RECORD
|
|
|
|
last: ITEM
|
|
|
|
END;
|
|
|
|
|
|
PROCEDURE push* (collection: COLLECTION; item: ITEM);
|
|
BEGIN
|
|
item.link := collection.last;
|
|
collection.last := item
|
|
END push;
|
|
|
|
|
|
PROCEDURE pop* (collection: COLLECTION): ITEM;
|
|
VAR
|
|
item: ITEM;
|
|
|
|
BEGIN
|
|
item := collection.last;
|
|
IF item # NIL THEN
|
|
collection.last := item.link
|
|
END
|
|
|
|
RETURN item
|
|
END pop;
|
|
|
|
|
|
PROCEDURE create* (): COLLECTION;
|
|
VAR
|
|
collection: COLLECTION;
|
|
|
|
BEGIN
|
|
NEW(collection);
|
|
collection.last := NIL
|
|
|
|
RETURN collection
|
|
END create;
|
|
|
|
|
|
END COLLECTIONS. |