1 Star 0 Fork 0

陈慧颖 / gooid

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
stack.go 585 Bytes
一键复制 编辑 原始数据 按行查看 历史
gooid 提交于 2018-11-27 19:42 . ImGui Tree Demo
package main
import "container/list"
type Stack struct {
l *list.List
}
func NewStack() *Stack {
return &Stack{l: list.New()}
}
func (s *Stack) Push(v interface{}) {
s.l.PushBack(v)
}
func (s *Stack) Pop() interface{} {
if e := s.l.Back(); e != nil {
s.l.Remove(e)
return e.Value
}
return nil
}
func (s *Stack) Poll(i int) interface{} {
if e := s.l.Back(); e != nil {
for ; i > 0 && e != nil; i-- {
e = e.Prev()
}
if e != nil {
return e.Value
}
}
return nil
}
func (s *Stack) Depth() int {
return s.l.Len()
}
func (s *Stack) Reset() {
s.l.Init()
}
1
https://gitee.com/githubchy/gooid.git
git@gitee.com:githubchy/gooid.git
githubchy
gooid
gooid
2c72341a60e5

搜索帮助