Pop Remove and return top element of Stack. Return false if Stack is empty.
()
| 27 | |
| 28 | // Pop Remove and return top element of Stack. Return false if Stack is empty. |
| 29 | func (s *Stack) Pop() interface{} { |
| 30 | index := len(*s) - 1 // Get the index of the top most element. |
| 31 | element := (*s)[index] // Index into the slice and obtain the element. |
| 32 | *s = (*s)[:index] // Remove it from the Stack by slicing it off. |
| 33 | return element |
| 34 | |
| 35 | } |
| 36 | |
| 37 | // Peek Peek value, not remove element. |
| 38 | func (s *Stack) Peek() interface{} { |
no outgoing calls