You've already forked Platinum_Reusable_Stack
mirror of
https://github.com/AdaCore/Platinum_Reusable_Stack.git
synced 2026-02-12 13:06:12 -08:00
50 lines
983 B
Ada
50 lines
983 B
Ada
--
|
|
-- Copyright (C) 2020, AdaCore
|
|
--
|
|
-- SPDX-License-Identifier: Apache-2.0
|
|
--
|
|
|
|
package body Sequential_Bounded_Stacks is
|
|
|
|
-----------
|
|
-- Reset --
|
|
-----------
|
|
|
|
procedure Reset (This : in out Stack) is
|
|
begin
|
|
This.Top := 0;
|
|
end Reset;
|
|
|
|
----------
|
|
-- Push --
|
|
----------
|
|
|
|
procedure Push (This : in out Stack; Item : in Element) is
|
|
begin
|
|
This.Top := This.Top + 1;
|
|
This.Values (This.Top) := Item;
|
|
end Push;
|
|
|
|
---------
|
|
-- Pop --
|
|
---------
|
|
|
|
procedure Pop (This : in out Stack; Item : out Element) is
|
|
begin
|
|
Item := This.Values (This.Top);
|
|
This.Top := This.Top - 1;
|
|
end Pop;
|
|
|
|
----------
|
|
-- Copy --
|
|
----------
|
|
|
|
procedure Copy (Destination : in out Stack; Source : Stack) is
|
|
subtype Contained is Element_Count range 1 .. Source.Top;
|
|
begin
|
|
Destination.Top := Source.Top;
|
|
Destination.Values (Contained) := Source.Values (Contained);
|
|
end Copy;
|
|
|
|
end Sequential_Bounded_Stacks;
|