summaryrefslogtreecommitdiff
path: root/stack/src/stack.ads
blob: 4f390e313413d1e9a94acbb89bae0ea9efc94cfe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
generic
   type T is private;
package Stack is
   type Stack is private;

   -- Push a value into the stack.
   procedure Push (S : in out Stack; Val : T);

   -- Pop a value from the stack.
   function Pop (S : in out Stack; Val : out T) return Boolean;

   -- Return true if the stack is empty, false otherwise.
   function Empty (S : Stack) return Boolean;
private
   type Node;
   type Node_Access is access Node;

   type Node is record
      Val    : T;
      Bottom : Node_Access;
   end record;

   type Stack is record
      Top : Node_Access;
   end record;
end Stack;