1--
2-- Copyright(C) 1998
3-- All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
4--
5-- Permission to use, copy, modify, and distribute this
6-- software and its documentation for EDUCATIONAL purposes
7-- and without fee is hereby granted provided that this
8-- copyright notice appears in all copies.
9--
10
11-- date : January 1, 1998.
12-- authorĀ : Salih Yurttas.
13
14-- queue_00_p.adb
15
16
17package body Queue_00_P is
18
19 function Full(Q : in Queue) return Boolean is
20 begin
21 return Q.Queue_Length = Queue_Size;
22 end Full;
23
24 function Empty(Q : in Queue) return Boolean is
25 begin
26 return Q.Queue_Length = 0;
27 end Empty;
28
29 procedure Enqueue(Q : in out Queue;
30 E : in Float) is
31 begin
32 if Full(Q) then
33 raise Overflow;
34 end if;
35
36 Q.Queue_Body((Q.Queue_Head+Q.Queue_Length) mod Queue_Size) := E;
37 Q.Queue_Length := Q.Queue_Length + 1;
38 end Enqueue;
39
40 procedure Dequeue(Q : in out Queue;
41 E : out Float) is
42 begin
43 if Empty(Q) then
44 raise Underflow;
45 end if;
46
47 E := Q.Queue_Body(Q.Queue_Head);
48 Q.Queue_Head := (Q.Queue_Head+1) mod Queue_Size;
49 Q.Queue_Length := Q.Queue_Length - 1;
50 end Dequeue;
51
52end Queue_00_P;