MCPcopy Index your code
hub / github.com/0xAX/go-algorithms / Pop

Method Pop

stack/stack.go:29–38  ·  view source on GitHub ↗

Deletes top of a stack and return it

()

Source from the content-addressed store, hash-verified

27
28// Deletes top of a stack and return it
29func (stack *Stack) Pop() interface{} {
30 if stack.depth > 0 {
31 item := stack.sp.item
32 stack.sp = stack.sp.next
33 stack.depth--
34 return item
35 }
36
37 return nil
38}
39
40// Peek returns top of a stack without deletion
41func (stack *Stack) Peek() interface{} {

Callers 1

TestStackFunction · 0.95

Calls

no outgoing calls

Tested by 1

TestStackFunction · 0.76