mirror of
https://github.com/AdaCore/spark2014.git
synced 2026-02-12 12:39:11 -08:00
21 lines
444 B
Ada
21 lines
444 B
Ada
package body QueueOperations
|
|
is
|
|
|
|
procedure ReverseQueue(Q : in out Queues.Queue)
|
|
is
|
|
S: Stacks.Stack;
|
|
X: Integer;
|
|
begin
|
|
Stacks.ClearStack(S);
|
|
while not Queues.EmptyQueue(Q) loop
|
|
Queues.DeQueue(Q, X);
|
|
Stacks.Push(S, X);
|
|
end loop;
|
|
while not Stacks.EmptyStack(S) loop
|
|
Stacks.Pop(S, X);
|
|
Queues.EnQueue(Q, X);
|
|
end loop;
|
|
end ReverseQueue;
|
|
|
|
end QueueOperations;
|