gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
polsuma - greska u redosledu parametara
[spa1skripta-public.git] / kodovi / stek-redopsl / RedOpsl.mod
1 IMPLEMENTATION MODULE RedOpsl;
2 FROM Info IMPORT InfoTip;
4 PROCEDURE MakeNull(VAR q : RedOpslTip);
5 BEGIN
6 WITH q DO
7 Prvi := 0;
8 Zadnji := 0
9 END
10 END MakeNull;
12 PROCEDURE Empty(VAR q : RedOpslTip) : BOOLEAN;
13 BEGIN
14 RETURN q.Zadnji = 0
15 END Empty;
17 PROCEDURE First(VAR q : RedOpslTip;
18 VAR x : InfoTip;
19 VAR ok : BOOLEAN);
20 BEGIN
21 IF Empty(q) THEN
22 ok := FALSE
23 ELSE
24 ok := TRUE;
25 WITH q DO
26 x := Element[Prvi]
27 END
28 END
29 END First;
31 PROCEDURE AddOne(i : CARDINAL) : CARDINAL;
32 BEGIN
33 IF i = Maxred THEN
34 RETURN 1
35 ELSE
36 RETURN i+1
37 END
38 END AddOne;
40 PROCEDURE PopFirst(VAR q : RedOpslTip;
41 VAR ok : BOOLEAN);
42 BEGIN
43 IF Empty(q) THEN
44 ok := FALSE
45 ELSE
46 ok := TRUE;
47 WITH q DO
48 IF Prvi = Zadnji THEN
49 MakeNull(q)
50 ELSE
51 Prvi := AddOne(Prvi)
52 END
53 END
54 END
55 END PopFirst;
57 PROCEDURE AddRear(VAR q : RedOpslTip;
58 x : InfoTip;
59 VAR ok : BOOLEAN);
60 BEGIN
61 WITH q DO
62 IF AddOne(Zadnji) = Prvi THEN
63 ok := FALSE
64 ELSE
65 ok := TRUE;
66 IF Empty(q) THEN
67 Prvi := 1;
68 Zadnji := 1
69 ELSE
70 Zadnji := AddOne(Zadnji)
71 END;
72 Element[Zadnji] := x
73 END
74 END
75 END AddRear;
77 END RedOpsl.
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner