mirror of
https://github.com/containers/podman.git
synced 2025-07-31 12:22:29 +08:00

Also update to c/image after https://github.com/containers/image/pull/1821 , so that we don't ship two versions of the package simultaneously. [NO NEW TESTS NEEDED] Signed-off-by: Miloslav Trmač <mitr@redhat.com>
34 lines
632 B
Go
34 lines
632 B
Go
package mpb
|
|
|
|
// A priorityQueue implements heap.Interface
|
|
type priorityQueue []*Bar
|
|
|
|
func (pq priorityQueue) Len() int { return len(pq) }
|
|
|
|
func (pq priorityQueue) Less(i, j int) bool {
|
|
// less priority pops first
|
|
return pq[i].priority > pq[j].priority
|
|
}
|
|
|
|
func (pq priorityQueue) Swap(i, j int) {
|
|
pq[i], pq[j] = pq[j], pq[i]
|
|
pq[i].index = i
|
|
pq[j].index = j
|
|
}
|
|
|
|
func (pq *priorityQueue) Push(x interface{}) {
|
|
s := *pq
|
|
bar := x.(*Bar)
|
|
bar.index = len(s)
|
|
s = append(s, bar)
|
|
*pq = s
|
|
}
|
|
|
|
func (pq *priorityQueue) Pop() interface{} {
|
|
s := *pq
|
|
*pq = s[0 : len(s)-1]
|
|
bar := s[len(s)-1]
|
|
bar.index = -1 // for safety
|
|
return bar
|
|
}
|