Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
removes unused priority heap key map
  • Loading branch information
owen-d committed Dec 11, 2024
commit f096e8b0f1af49d6e0761b52ee63f67923ff9384
6 changes: 0 additions & 6 deletions pkg/blockbuilder/scheduler/priority_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ func NewPriorityQueue[K comparable, V any](less func(V, V) bool, key func(V) K)
h := &priorityHeap[V]{
less: less,
heap: make([]*item[V], 0),
idx: make(map[int]*item[V]),
}
heap.Init(h)
return &PriorityQueue[K, V]{
Expand Down Expand Up @@ -100,7 +99,6 @@ func (pq *PriorityQueue[K, V]) Len() int {
type priorityHeap[V any] struct {
less func(V, V) bool
heap []*item[V]
idx map[int]*item[V] // Maps index to item for efficient updates
}

func (h *priorityHeap[V]) Len() int {
Expand All @@ -115,23 +113,19 @@ func (h *priorityHeap[V]) Swap(i, j int) {
h.heap[i], h.heap[j] = h.heap[j], h.heap[i]
h.heap[i].index = i
h.heap[j].index = j
h.idx[i] = h.heap[i]
h.idx[j] = h.heap[j]
}

func (h *priorityHeap[V]) Push(x any) {
it := x.(*item[V])
it.index = len(h.heap)
h.heap = append(h.heap, it)
h.idx[it.index] = it
}

func (h *priorityHeap[V]) Pop() any {
old := h.heap
n := len(old)
it := old[n-1]
h.heap = old[0 : n-1]
delete(h.idx, it.index)
return it
}

Expand Down