mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-28 19:19:57 +00:00
TUN-1350: Enhance error messages with cloudflarestatus.com link, if relevant
This commit is contained in:
37
vendor/github.com/cloudflare/golibs/lrucache/priorityqueue.go
generated
vendored
Normal file
37
vendor/github.com/cloudflare/golibs/lrucache/priorityqueue.go
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
// Copyright (c) 2013 CloudFlare, Inc.
|
||||
|
||||
// This code is based on golang example from "container/heap" package.
|
||||
|
||||
package lrucache
|
||||
|
||||
type priorityQueue []*entry
|
||||
|
||||
func (pq priorityQueue) Len() int {
|
||||
return len(pq)
|
||||
}
|
||||
|
||||
func (pq priorityQueue) Less(i, j int) bool {
|
||||
return pq[i].expire.Before(pq[j].expire)
|
||||
}
|
||||
|
||||
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(e interface{}) {
|
||||
n := len(*pq)
|
||||
item := e.(*entry)
|
||||
item.index = n
|
||||
*pq = append(*pq, item)
|
||||
}
|
||||
|
||||
func (pq *priorityQueue) Pop() interface{} {
|
||||
old := *pq
|
||||
n := len(old)
|
||||
item := old[n-1]
|
||||
item.index = -1
|
||||
*pq = old[0 : n-1]
|
||||
return item
|
||||
}
|
Reference in New Issue
Block a user