aboutsummaryrefslogtreecommitdiff
path: root/pkg/pointer/stack.go
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--pkg/pointer/stack.go53
1 files changed, 6 insertions, 47 deletions
diff --git a/pkg/pointer/stack.go b/pkg/pointer/stack.go
index ba51c7c..b08b354 100644
--- a/pkg/pointer/stack.go
+++ b/pkg/pointer/stack.go
@@ -1,54 +1,13 @@
package pointer
-type Stack struct {
- size int
- height int
- data []int
- next *Stack // Pointer to the next element in the stack stack
+func (ss *StackStack) Pop() int {
+ return ss.head.Pop()
}
-func NewStack() *Stack {
- return &Stack{
- size: 32,
- height: 0,
- data: make([]int, 32),
- next: nil,
- }
+func (ss *StackStack) Push(v int) {
+ ss.head.Push(v)
}
-func (s *Stack) Clear() {
- s.height = 0
-}
-
-func (s *Stack) Duplicate() {
- if s.height > 0 {
- s.Push(s.data[s.height-1])
- } else {
- s.Push(0)
- s.Push(0)
- }
-}
-
-func (s *Stack) Pop() int {
- if s.height > 0 {
- s.height--
- return s.data[s.height]
- }
- return 0
-}
-
-func (s *Stack) Push(value int) {
- if s.height >= s.size {
- s.size += 32
- s.data = append(s.data, make([]int, 32)...)
- }
- s.data[s.height] = value
- s.height++
-}
-
-func (s *Stack) Swap() {
- a := s.Pop()
- b := s.Pop()
- s.Push(a)
- s.Push(b)
+func (s *StackStack) YCommandPick(n int, h int) {
+ s.head.YCommandPick(n, h)
}