// Heap methods: do not use directly
493465
func (brh blockRetrievalHeap) Less(i, j int) bool {
	reqI := brh[i]
	reqJ := brh[j]
	if reqI.priority > reqJ.priority {
		return true
	}
	if reqI.priority < reqJ.priority {
		return false
	}
	return reqI.insertionOrder < reqJ.insertionOrder
}
1051559
func (heap *FloatingFibonacciHeap) Delete(node *Entry) error {

	if heap.IsEmpty() {
		return EmptyHeapError("Cannot delete element from an empty heap")
	}

	if node == nil {
		return NilError("Cannot delete node: given node is nil")
	}

	decreaseKeyUnchecked(heap, node, -math.MaxFloat64)
	heap.DequeueMin()
	return nil
}
322049
func (p *PeriodicDispatch) flush() {
	p.updateCh = make(chan struct{}, 1)
	p.tracked = make(map[structs.NamespacedID]*structs.Job)
	p.heap = NewPeriodicHeap()
	p.stopFn = nil
}
512183
func StartupWait(t time.Duration) HeapOption {
	return func(c *heapConfig) {
		c.startupWait = t
	}
}
295226
func (ha *Heap) Update() {
	ha.m.Lock()
	defer ha.m.Unlock()

	runtime.ReadMemStats(&ha.mem)
	ha.g.Update(int64(ha.mem.HeapAlloc))
}
1366864
func buildHuffmanTree(symFreqs []int) huffmanTree {
	var trees treeHeap
	for v, w := range symFreqs {
		if w == 0 {
			w = 1
		}

		trees = append(trees, &huffmanLeaf{w, v})
	}

	n := 40

	heap.Init(&trees)
	for trees.Len() > 1 {
		a := heap.Pop(&trees).(huffmanTree)
		b := heap.Pop(&trees).(huffmanTree)

		heap.Push(&trees, &huffmanNode{a.Weight() + b.Weight(), n, a, b})
		n++
	}

	return heap.Pop(&trees).(huffmanTree)
}
768238
func (r *Application) Memory(memory float64) *Application {
	r.Mem = &memory

	return r
}
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")
}
165885
func newSingleConnectionHeap(size int) *singleConnectionHeap {
	if size <= 0 {
		panic("Heap size cannot be less than 1")
	}

	return &singleConnectionHeap{
		full: false,
		data: make([]*Connection, uint32(size)),
		size: uint32(size),
	}
}
770256
func heapSort_func(data lessSwap, a, b int) {
	first := a
	lo := 0
	hi := b - a
	for i := (hi - 1) / 2; i >= 0; i-- {
		siftDown_func(data, i, hi, first)
	}
	for i := hi - 1; i >= 0; i-- {
		data.Swap(first, first+i)
		siftDown_func(data, lo, i, first)
	}
}
569013
func (this *DatabaseProfilerMemory) Flush() {
	this.Lock()
	count := len(this.Log)
	for _, line := range this.Log[:count] {
		fmt.Println(line)
	}
	this.Log = this.Log[count:]
	this.Unlock()
}
612367
func HeapOr(bitmaps ...*Bitmap) *Bitmap {
	if len(bitmaps) == 0 {
		return NewBitmap()
	}
	// TODO:  for better speed, we could do the operation lazily, see Java implementation
	pq := make(priorityQueue, len(bitmaps))
	for i, bm := range bitmaps {
		pq[i] = &item{bm, i}
	}
	heap.Init(&pq)

	for pq.Len() > 1 {
		x1 := heap.Pop(&pq).(*item)
		x2 := heap.Pop(&pq).(*item)
		heap.Push(&pq, &item{Or(x1.value, x2.value), 0})
	}
	return heap.Pop(&pq).(*item).value
}
275390
func (r *runtimeSample) drain(stats Stats) {
	stats.Gauge("runtime.NumGoroutine", float32(r.NumGoroutine), 1.0, nil)
	stats.Gauge("runtime.MemStats.Alloc", float32(r.MemStats.Alloc), 1.0, nil)
	stats.Gauge("runtime.MemStats.Frees", float32(r.MemStats.Frees), 1.0, nil)
	stats.Gauge("runtime.MemStats.HeapAlloc", float32(r.MemStats.HeapAlloc), 1.0, nil)
	stats.Gauge("runtime.MemStats.HeapIdle", float32(r.MemStats.HeapIdle), 1.0, nil)
	stats.Gauge("runtime.MemStats.HeapObjects", float32(r.MemStats.HeapObjects), 1.0, nil)
	stats.Gauge("runtime.MemStats.HeapReleased", float32(r.MemStats.HeapReleased), 1.0, nil)
	stats.Gauge("runtime.MemStats.HeapSys", float32(r.MemStats.HeapSys), 1.0, nil)
	stats.Gauge("runtime.MemStats.LastGC", float32(r.MemStats.LastGC), 1.0, nil)
	stats.Gauge("runtime.MemStats.Lookups", float32(r.MemStats.Lookups), 1.0, nil)
	stats.Gauge("runtime.MemStats.Mallocs", float32(r.MemStats.Mallocs), 1.0, nil)
	stats.Gauge("runtime.MemStats.MCacheInuse", float32(r.MemStats.MCacheInuse), 1.0, nil)
	stats.Gauge("runtime.MemStats.MCacheSys", float32(r.MemStats.MCacheSys), 1.0, nil)
	stats.Gauge("runtime.MemStats.MSpanInuse", float32(r.MemStats.MSpanInuse), 1.0, nil)
	stats.Gauge("runtime.MemStats.MSpanSys", float32(r.MemStats.MSpanSys), 1.0, nil)
	stats.Gauge("runtime.MemStats.NextGC", float32(r.MemStats.NextGC), 1.0, nil)
	stats.Gauge("runtime.MemStats.NumGC", float32(r.MemStats.NumGC), 1.0, nil)
	stats.Gauge("runtime.MemStats.StackInuse", float32(r.MemStats.StackInuse), 1.0, nil)
}
1353574
func PushLastF(Len int, Less func(i, j int) bool, Swap func(i, j int)) {
	heapUp(Less, Swap, Len-1)
}
1091264
func (d *Context) DestroyHeap() {
	d.Gc(0)
	C.duk_destroy_heap(d.duk_context)
	d.duk_context = nil
}
166998
func (self *ResourceList) Memory() *resource.Quantity {
	if val, ok := (*self)[ResourceMemory]; ok {
		return &val
	}
	return &resource.Quantity{}
}
776256
func (p *Prque) Remove(i int) interface{} {
	if i < 0 {
		return nil
	}
	return heap.Remove(p.cont, i)
}