Deletes top of a stack and return it
()
| 27 | |
| 28 | // Deletes top of a stack and return it |
| 29 | func (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 |
| 41 | func (stack *Stack) Peek() interface{} { |