Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package body is Stack
- Maximum_Size : Constant := 64;
- Top : Integer := 0;
- Stack_List : array (1 .. Maximum_Size) of Integer;
- procedure Push(Obj : in Integer) is
- begin
- if not Is_Full then
- Top := Top + 1;
- Stack_List(Top) := Obj;
- end if;
- end Push;
- procedure Pop(Obj : out Integer) is
- begin
- if Is_Empty then
- Obj := 0;
- else
- Obj := Stack_List(Top);
- Top := Top - 1;
- end if
- end Pop;
- function Is_Empty return Boolean is
- begin
- return Top = 0;
- end Is_Empty;
- function Is_Full return Boolean is
- begin
- return Top = Maximum_Size;
- end Is_Full;
- function Current_Size return Integer is
- begin
- return Top;
- end Current_Size;
- procedure Clear is
- begin
- Top := 0;
- end Clear;
- end Stack;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement