gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
verzija je sad 14b za buduce promene
[spa1skripta-public.git] / kodovi / REDOPSL1.MOD
1 IMPLEMENTATION MODULE RedOpsl1;
2 FROM QueueInfo IMPORT Maxqueue,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;
18 PROCEDURE First(VAR q : RedOpslTip;
19 VAR x : InfoTip;
20 VAR ok : BOOLEAN);
21 BEGIN
22 IF Empty(q) THEN
23 ok := FALSE
24 ELSE
25 ok := TRUE;
26 WITH q DO
27 x := Element[Prvi]
28 END
29 END
30 END First;
32 PROCEDURE AddOne(i : CARDINAL) : CARDINAL;
33 BEGIN
34 IF i = Maxqueue THEN
35 RETURN 1
36 ELSE
37 RETURN i+1
38 END
39 END AddOne;
41 PROCEDURE PopFirst(VAR q : RedOpslTip;
42 VAR ok : BOOLEAN);
43 BEGIN
44 IF Empty(q) THEN
45 ok := FALSE
46 ELSE
47 ok := TRUE;
48 WITH q DO
49 IF Prvi = Zadnji THEN
50 MakeNull(q)
51 ELSE
52 Prvi := AddOne(Prvi)
53 END
54 END
55 END
56 END PopFirst;
58 PROCEDURE AddRear(VAR q : RedOpslTip;
59 x : InfoTip;
60 VAR ok : BOOLEAN);
61 BEGIN
62 WITH q DO
63 IF AddOne(Zadnji) = Prvi THEN
64 ok := FALSE
65 ELSE
66 ok := TRUE;
67 IF Empty(q) THEN
68 Prvi := 1;
69 Zadnji := 1
70 ELSE
71 Zadnji := AddOne(Zadnji)
72 END;
73 Element[Zadnji] := x
74 END
75 END
76 END AddRear;
78 END RedOpsl1.
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner