summaryrefslogtreecommitdiff
path: root/vendor/github.com/vbauerster/mpb/v7/priority_queue.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2021-06-16 05:57:09 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2021-06-17 14:59:42 -0400
commitb6662eed3f27ac5466501b046db4f1608845af61 (patch)
tree7a4f80a77f812505a6261bc11ed8151235f903f1 /vendor/github.com/vbauerster/mpb/v7/priority_queue.go
parent725b5001a17f703d95a3c88e4f58225c5290576b (diff)
downloadpodman-b6662eed3f27ac5466501b046db4f1608845af61.tar.gz
podman-b6662eed3f27ac5466501b046db4f1608845af61.tar.bz2
podman-b6662eed3f27ac5466501b046db4f1608845af61.zip
Vendor in containers/common v0.40.0
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'vendor/github.com/vbauerster/mpb/v7/priority_queue.go')
-rw-r--r--vendor/github.com/vbauerster/mpb/v7/priority_queue.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/vendor/github.com/vbauerster/mpb/v7/priority_queue.go b/vendor/github.com/vbauerster/mpb/v7/priority_queue.go
new file mode 100644
index 000000000..29d9bd5a8
--- /dev/null
+++ b/vendor/github.com/vbauerster/mpb/v7/priority_queue.go
@@ -0,0 +1,32 @@
+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 {
+ 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
+}