-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCLSQUEUE.srvscr
79 lines (48 loc) · 1.5 KB
/
CLSQUEUE.srvscr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/********************************************************************************
Description.. : FIFO data structure
Methods...... : size() - returns the length of the queue.
put() - enqueues an item
peek() - returns the top element, without dequeueing it
get() - returns and removes the top element
Returns...... : -
Author....... : ZWOLAKT
Date......... : 2012-06-14
********************************************************************************
_______________________________________________________________________________
Ticket #..... :
Modification. :
Author....... :
Date......... :
_______________________________________________________________________________
********************************************************************************/;
:CLASS Queue;
:DECLARE _queue;
:PROCEDURE constructor;
/* initialize the queue array ;
Me:_queue := {};
:ENDPROC;
:PROCEDURE size;
/* return the number of items in the queue ;
:RETURN Len( Me:_queue );
:ENDPROC;
:PROCEDURE peek;
/* return the top element without dequeuing it ;
/* copy the item to memory ;
:RETURN Me:_queue[1];
:ENDPROC;
:PROCEDURE put;
:PARAMETERS item;
/* enqueue item ;
aAdd( Me:_queue, item );
:ENDPROC;
:PROCEDURE get;
:DECLARE item;
:IF Len( Me:_queue ) = 0 ;
RaiseError( "Queue Size is Zero!", "DataStructures.clsQueue:pop()", 12535 );
:ENDIF;
/* copy the first item to memory ;
item := Me:peek();
/* Delete the first item ;
DelArray( Me:_queue, 1 );
:RETURN item ;
:ENDPROC;