// Poll removes and returns an item from the heap.
// If the heap is empty, nil will be returned.
335044
func (h *singleConnectionHeap) Poll() (res *Connection) {
	h.mutex.Lock()
	// if heap is not empty
	if (h.tail != h.head) || h.full {
		res = h.data[h.head]
		h.data[h.head] = nil

		h.full = false
		if h.head == 0 {
			h.head = h.size - 1
		} else {
			h.head--
		}
	}

	h.mutex.Unlock()
	return res
}
664732
func (s *Deque) Pop() interface{} {
	s.Lock()
	defer s.Unlock()

	var item interface{} = nil
	var lastContainerItem *list.Element = nil

	lastContainerItem = s.container.Back()
	if lastContainerItem != nil {
		item = s.container.Remove(lastContainerItem)
	}

	return item
}
903236
func (o *OAuthSession) Vote(v Voter, dir Vote) error {
	// Build form for POST request.
	form := url.Values{
		"id":  {v.voteID()},
		"dir": {string(dir)},
	}
	var vo interface{}

	err := o.postBody("https://oauth.reddit.com/api/vote", form, vo)
	if err != nil {
		return err
	}
	return nil
}
33708
func (h *Heap) Delete(obj interface{}) error {
	key, err := h.data.keyFunc(obj)
	if err != nil {
		return KeyError{obj, err}
	}
	h.lock.Lock()
	defer h.lock.Unlock()
	if item, ok := h.data.items[key]; ok {
		heap.Remove(h.data, item.index)
		return nil
	}
	return fmt.Errorf("object not found")
}
429197
func (s *Stream) Poll() (bool, error) {
	poll := C.Pm_Poll(unsafe.Pointer(s.pmStream))
	if poll < 0 {
		return false, convertToError(C.PmError(poll))
	}
	return poll > 0, nil
}
72933
func (c *MemoryCacher) Get(key string) interface{} {
	c.lock.RLock()
	defer c.lock.RUnlock()

	item, ok := c.items[key]
	if !ok {
		return nil
	}
	if item.hasExpired() {
		go c.Delete(key)
		return nil
	}
	return item.val
}
220819
func (p *LongPoller) Poll(b *Bot, dest chan Update, stop chan struct{}) {
	go func(stop chan struct{}) {
		<-stop
		close(stop)
	}(stop)

	for {
		updates, err := b.getUpdates(p.LastUpdateID+1, p.Timeout)

		if err != nil {
			b.debug(ErrCouldNotUpdate)
			continue
		}

		for _, update := range updates {
			p.LastUpdateID = update.ID
			dest <- update
		}
	}
}
636801
func (h *Heap) Get(obj interface{}) (interface{}, bool, error) {
	key, err := h.data.keyFunc(obj)
	if err != nil {
		return nil, false, KeyError{obj, err}
	}
	return h.GetByKey(key)
}
17455
func (h *heapData) Swap(i, j int) {
	h.queue[i], h.queue[j] = h.queue[j], h.queue[i]
	item := h.items[h.queue[i]]
	item.index = i
	item = h.items[h.queue[j]]
	item.index = j
}
21429
func (m *SyncMap) Pop() (string, interface{}) {
	if m.Size() == 0 {
		panic("syncmap: map is empty")
	}

	var (
		key   string
		value interface{}
		found = false
		n     = int(m.shardCount)
	)

	for !found {
		idx := rand.Intn(n)
		shard := m.shards[idx]
		shard.Lock()
		if len(shard.items) > 0 {
			found = true
			for key, value = range shard.items {
				break
			}
			delete(shard.items, key)
		}
		shard.Unlock()
	}

	return key, value
}
611018
func (s *RankedSet) Delete(item Item) Item {
	key := item.Key()
	value, ok := s.set[key]
	if !ok {
		return nil
	}

	s.rank.Delete(value) // should always return the same data as value (non-nil)
	delete(s.set, key)

	return value.item
}
67142
func (pq *ScoreHeap) Pop() interface{} {
	old := pq.items
	n := len(old)
	item := old[n-1]
	pq.items = old[0 : n-1]
	return item
}
388084
func (r *MemoryNoTS) Get(key string) (interface{}, error) {
	value, ok := r.items[key]
	if !ok {
		return nil, ErrNotFound
	}

	return value, nil
}
250780
func (m *BottomK) Push(b []byte) {

	i64 := m.h(b)

	if i64 == 0 {
		return
	}

	if len(*m.minimums) < m.size {
		heap.Push(m.minimums, i64)
		return
	}

	if i64 < (*m.minimums)[0] {
		(*m.minimums)[0] = i64
		heap.Fix(m.minimums, 0)
	}
}
439591
func (q *prioQueue) Push(v int) {
	n := q.Len()
	q.heap = append(q.heap, v)
	q.index[v] = n
	q.up(n)
}
597790
func (h *heapData) Less(i, j int) bool {
	if i > len(h.queue) || j > len(h.queue) {
		return false
	}
	itemi, ok := h.items[h.queue[i]]
	if !ok {
		return false
	}
	itemj, ok := h.items[h.queue[j]]
	if !ok {
		return false
	}
	return h.lessFunc(itemi.obj, itemj.obj)
}
36463
func (s *Schedule) Remove(key interface{}) {
	if item, ok := s.m[key]; ok {
		heap.Remove(&s.items, item.i)
		delete(s.m, key)
	}
}