mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
refactor add newTTLKeyHeap function
This commit is contained in:
parent
b9593b80ec
commit
c05df9e3f5
@ -8,8 +8,7 @@ import (
|
||||
)
|
||||
|
||||
func TestHeapPushPop(t *testing.T) {
|
||||
h := &TTLKeyHeap{Map: make(map[*Node]int)}
|
||||
heap.Init(h)
|
||||
h := newTTLKeyHeap()
|
||||
|
||||
// add from older expire time to earlier expire time
|
||||
// the path is equal to ttl from now
|
||||
|
@ -10,6 +10,12 @@ type TTLKeyHeap struct {
|
||||
Map map[*Node]int
|
||||
}
|
||||
|
||||
func newTTLKeyHeap() *TTLKeyHeap {
|
||||
h := &TTLKeyHeap{Map: make(map[*Node]int)}
|
||||
heap.Init(h)
|
||||
return h
|
||||
}
|
||||
|
||||
func (h TTLKeyHeap) Len() int {
|
||||
return len(h.Array)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user