diff options
author | 3gg <3gg@shellblade.net> | 2025-08-09 16:03:28 +0200 |
---|---|---|
committer | 3gg <3gg@shellblade.net> | 2025-08-09 16:03:28 +0200 |
commit | 727e3c59346da4f91284b34b4c18f2e0ba155e53 (patch) | |
tree | 807dccd5cba3c6bae2f8d0c9910157e306c6da5b /stack/src/stack.ads |
Diffstat (limited to 'stack/src/stack.ads')
-rw-r--r-- | stack/src/stack.ads | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/stack/src/stack.ads b/stack/src/stack.ads new file mode 100644 index 0000000..4f390e3 --- /dev/null +++ b/stack/src/stack.ads | |||
@@ -0,0 +1,26 @@ | |||
1 | generic | ||
2 | type T is private; | ||
3 | package Stack is | ||
4 | type Stack is private; | ||
5 | |||
6 | -- Push a value into the stack. | ||
7 | procedure Push (S : in out Stack; Val : T); | ||
8 | |||
9 | -- Pop a value from the stack. | ||
10 | function Pop (S : in out Stack; Val : out T) return Boolean; | ||
11 | |||
12 | -- Return true if the stack is empty, false otherwise. | ||
13 | function Empty (S : Stack) return Boolean; | ||
14 | private | ||
15 | type Node; | ||
16 | type Node_Access is access Node; | ||
17 | |||
18 | type Node is record | ||
19 | Val : T; | ||
20 | Bottom : Node_Access; | ||
21 | end record; | ||
22 | |||
23 | type Stack is record | ||
24 | Top : Node_Access; | ||
25 | end record; | ||
26 | end Stack; | ||