/* * Copyright 2016-2018 Dgraph Labs, Inc. * * This file is available under the Apache License, Version 2.0, * with the Commons Clause restriction. */ package algo type elem struct { val uint64 // Value of this element. listIdx int // Which list this element comes from. } type uint64Heap []elem func (h uint64Heap) Len() int { return len(h) } func (h uint64Heap) Less(i, j int) bool { return h[i].val < h[j].val } func (h uint64Heap) Swap(i, j int) { h[i], h[j] = h[j], h[i] } func (h *uint64Heap) Push(x interface{}) { *h = append(*h, x.(elem)) } func (h *uint64Heap) Pop() interface{} { old := *h n := len(old) x := old[n-1] *h = old[0 : n-1] return x }