Pop pops the first item from the stack
()
| 29 | |
| 30 | // Pop pops the first item from the stack |
| 31 | func (s *Stack) Pop() int { |
| 32 | s.lock.Lock() |
| 33 | defer s.lock.Unlock() |
| 34 | if s.items.Len() < s.maxSize { |
| 35 | return -1 |
| 36 | } |
| 37 | item := s.items.Front() |
| 38 | if nil == item { |
| 39 | return -1 |
| 40 | } |
| 41 | s.items.Remove(item) |
| 42 | return item.Value.(int) |
| 43 | } |
| 44 | |
| 45 | // Touch moves the specified item to the last position of the stack |
| 46 | func (s *Stack) Touch(item *list.Element) { |