-
Notifications
You must be signed in to change notification settings - Fork 0
/
float64stack_gen.go
58 lines (47 loc) · 956 Bytes
/
float64stack_gen.go
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Code generated by stacker -type float64 ; DO NOT EDIT
package main
type float64Stack struct {
data []float64
}
func (s *float64Stack) Push(v float64) {
s.data = append(s.data, v)
}
func (s *float64Stack) Pop() (v float64, ok bool) {
if len(s.data) == 0 {
return v, false
}
top := len(s.data) - 1
v = s.data[top]
s.data = s.data[:top]
return v, true
}
func (s *float64Stack) Peek() (v float64, ok bool) {
if len(s.data) == 0 {
return v, false
}
top := len(s.data) - 1
v = s.data[top]
return v, true
}
func (s *float64Stack) Len() int {
return len(s.data)
}
func (s *float64Stack) Walk(f func(float64)) {
for _, v := range s.data {
f(v)
}
}
func (s *float64Stack) Rotate() {
if len(s.data) == 0 {
return
}
top := len(s.data) - 1
s.data = append(s.data[top:], s.data[:top]...)
}
func (s *float64Stack) Unrotate() {
if len(s.data) == 0 {
return
}
bottom := 0
s.data = append(s.data[bottom+1:], s.data[bottom])
}