Queue/Usage: Difference between revisions

Add Cowgol
(Added 11l)
(Add Cowgol)
Line 621:
Is empty: $TRUE
</pre>
 
=={{header|Cowgol}}==
 
This code uses the queue code at [[Queue/Definition]], which should be put
in a file named <code>queue.coh</code>.
 
<lang cowgol>include "cowgol.coh";
 
typedef QueueData is uint8; # the queue will contain bytes
include "queue.coh"; # from the Queue/Definition task
 
var queue := MakeQueue();
 
# enqueue bytes 0 to 20
print("Enqueueing: ");
var n: uint8 := 0;
while n < 20 loop
print_i8(n);
print_char(' ');
Enqueue(queue, n);
n := n + 1;
end loop;
print_nl();
 
# dequeue and print everything in the queue
print("Dequeueing: ");
while QueueEmpty(queue) == 0 loop
print_i8(Dequeue(queue));
print_char(' ');
end loop;
print_nl();
 
# free the queue
FreeQueue(queue);</lang>
 
{{out}}
 
<pre>Enqueueing: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Dequeueing: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19</pre>
 
=={{header|D}}==
2,114

edits