// Pop retrieves the topmost element from the stack.
// A LimitError is returned when the stack is empty.
167969
func (s *Stack) Pop() (interface{}, error) {
	spin := s.spin
	for {
		head := atomic.LoadUint32(s.head)
		unlockedHead := head & unlockMask
		lockedHead := head | lockMask

		// Always work with unlocked head as head might be locked
		if unlockedHead == 0 {
			return nil, LimitError{"Stack is empty"}
		}

		if atomic.CompareAndSwapUint32(s.head, unlockedHead, lockedHead) {
			data := s.data[unlockedHead-1]             // copy data
			atomic.StoreUint32(s.head, unlockedHead-1) // unlock
			return data, nil                           // ### return ###
		}

		spin.Yield()
	}
}
743850
func (h *expiryHeap) Pop() interface{} {
	old := h.Entries
	n := len(old)
	x := old[n-1]
	h.Entries = old[0 : n-1]
	return x
}
1356250
func (h *heapData) Pop() interface{} {
	key := h.queue[len(h.queue)-1]
	h.queue = h.queue[0 : len(h.queue)-1]
	item, ok := h.items[key]
	if !ok {
		// This is an error
		return nil
	}
	delete(h.items, key)
	return item.obj
}
325087
func (p *PopOp) Pop(id string) bool {
	if p.finished {
		panic("the operation has already been finished")
	}
	if !p.CanPop(id) {
		return false
	}
	p.tombs[id] = p.now
	p.popped = append(p.popped, &tombstone{
		id:      id,
		storage: p.idToKeys[id],
	})
	p.dirty = true
	return true
}
902895
func (pq *BlockPriorityQueue) Pop() interface{} {
	n := pq.Len()
	old := pq.bh
	block := old[n-1]
	block.heapIdx = -1
	pq.bh = old[0 : n-1]
	return block
}
46553
func (h *Strings) Pop() string {
	if h.less == nil {
		PopToLastF(len(h.list), h.list.Less, h.list.Swap)
	} else {
		PopToLastF(len(h.list), h.less, h.list.Swap)
	}

	res := h.list[len(h.list)-1]
	h.list[len(h.list)-1] = "" // remove the reference in h.list
	h.list = h.list[:len(h.list)-1]

	return res
}
103037
func (l *List) Pop() (b Buffer) {
	b = (*l)[0]
	*l = (*l)[1:]
	return b
}
655886
func (ph *peerHeap) Pop() interface{} {
	lastIdx := len(ph.peers) - 1
	last := ph.peers[lastIdx]
	ph.peers = ph.peers[:lastIdx]
	return last
}
423681
func (h *Heap) Pop() (interface{}, error) {
	obj := heap.Pop(h.data)
	if obj != nil {
		if h.metricRecorder != nil {
			h.metricRecorder.Dec()
		}
		return obj, nil
	}
	return nil, fmt.Errorf("object was removed from heap data")
}
657456
func (h *TimedQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}
918332
func (s *scopeStack) pop() {
	s.scopes = s.scopes[0 : len(s.scopes)-1]
}
601054
func (th *treeHeap) Pop() (popped interface{}) {
	popped = (*th)[len(*th)-1]
	*th = (*th)[:len(*th)-1]
	return
}
203967
func (q *BytesQueue) Pop() ([]byte, error) {
	data, size, err := q.peek(q.head)
	if err != nil {
		return nil, err
	}

	q.head += headerEntrySize + size
	q.count--

	if q.head == q.rightMargin {
		q.head = leftMarginIndex
		if q.tail == q.rightMargin {
			q.tail = leftMarginIndex
		}
		q.rightMargin = q.tail
	}

	return data, nil
}
510772
func Pop(n int) MutatorFunc {
	return func(state *LexerState) error {
		if len(state.Stack) == 0 {
			return fmt.Errorf("nothing to pop")
		}
		state.Stack = state.Stack[:len(state.Stack)-n]
		return nil
	}
}
447722
func (s *items) pop() (out Item) {
	index := len(*s) - 1
	out = (*s)[index]
	(*s)[index] = nil
	*s = (*s)[:index]
	return
}
984337
func (b *Buffer) Pop(n int) {
	b.data = b.data[n:]
}
638550
func (n *Manager) Pop() (string, bool) {
	n.Lock()
	defer n.Unlock()

	if len(n.nonces) == 0 {
		return "", false
	}

	nonce := n.nonces[len(n.nonces)-1]
	n.nonces = n.nonces[:len(n.nonces)-1]
	return nonce, true
}