MCPcopy Create free account
hub / github.com/GoSimplicity/LinkMe / Pop

Method Pop

pkg/priorityqueue/priority_queue.go:60–69  ·  view source on GitHub ↗

Pop 移除并返回最小元素

()

Source from the content-addressed store, hash-verified

58
59// Pop 移除并返回最小元素
60func (pq *PriorityQueue[T]) Pop() interface{} {
61 if len(pq.items) == 0 {
62 return nil
63 }
64 old := pq.items
65 n := len(old)
66 item := old[n-1]
67 pq.items = old[0 : n-1]
68 return item
69}
70
71// Enqueue 添加一个元素
72func (pq *PriorityQueue[T]) Enqueue(item T) error {

Callers 1

DequeueMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected