RosettaCodeData/Task/Queue-Usage/Cowgol/queue-usage.cowgol

29 lines
558 B
Plaintext

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);