Initial Git commit
[ede] / explorer / src / Structures / Stack.ec
1 public import "ecere"
2
3 import "ArrayFactoredGrowth"
4
5 private:
6
7 public class Stack : Array
8 {
9 }
10
11 public class IntStack : Stack
12 {
13    type = class(int);
14 public:
15    int * const _;
16    void Push(int item)
17    {
18       uint pos = _count;
19       Append(1);
20       _[pos] = item;
21    }
22    int Pop()
23    {
24       int item = _[_count - 1];
25       Trim(1);
26       return item;
27    }
28 }
29
30 class UintStack : Stack
31 {
32    type = class(uint);
33 public:
34    uint * const _;
35    void Push(uint item)
36    {
37       uint pos = _count;
38       Append(1);
39       _[pos] = item;
40    }
41    uint Pop()
42    {
43       uint item = _[_count - 1];
44       Trim(1);
45       return item;
46    }
47 }
48
49 class StringStack : Stack
50 {
51    type = class(String);
52 public:
53    String * const _;
54    void Push(String item)
55    {
56       uint pos = _count;
57       Append(1);
58       _[pos] = item;
59    }
60    String Pop()
61    {
62       String item = _[_count - 1];
63       Trim(1);
64       return item;
65    }
66 }