MCPcopy
hub / github.com/hwholiday/learning_tools / TestHeap

Function TestHeap

container/heap/heap_test.go:8–29  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

6)
7
8func TestHeap(t *testing.T) {
9 queue := make(Queue, 10)
10 for i := 0; i < 10; i++ {
11 item:=&Item{
12 data: i + 1,
13 ref: i + 1,
14 index: i,
15 }
16 queue[i] = item
17 }
18 heap.Init(&queue)
19 item := Item{
20 data: 8,
21 ref: 1,
22 }
23 heap.Push(&queue, &item)
24 heap.Fix(&queue, 2)
25 for queue.Len() > 0 {
26 item := heap.Pop(&queue).(*Item)
27 t.Log("index", item.index, "ref", item.ref, "val", item.data)
28 }
29}

Callers

nothing calls this directly

Calls 4

PopMethod · 0.80
InitMethod · 0.65
PushMethod · 0.65
LenMethod · 0.45

Tested by

no test coverage detected