mirror of
https://github.com/divan/expvarmon.git
synced 2025-04-27 13:48:55 +08:00
21 lines
288 B
Go
21 lines
288 B
Go
package main
|
|
|
|
type Stack struct {
|
|
Values []int
|
|
Len int
|
|
}
|
|
|
|
func NewStack(size int) *Stack {
|
|
return &Stack{
|
|
Values: make([]int, size),
|
|
Len: size,
|
|
}
|
|
}
|
|
|
|
func (s *Stack) Push(val int) {
|
|
s.Values = append(s.Values, val)
|
|
if len(s.Values) > s.Len {
|
|
s.Values = s.Values[1:]
|
|
}
|
|
}
|