From 040b572d95e4ca27e1ada6113c405b8a1eb4a669 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Wed, 11 Mar 2026 20:41:32 +0800 Subject: commitquery: Merge from ancestor and mergebases --- internal/commitquery/priority_queue.go | 68 ---------------------------------- 1 file changed, 68 deletions(-) delete mode 100644 internal/commitquery/priority_queue.go (limited to 'internal/commitquery/priority_queue.go') diff --git a/internal/commitquery/priority_queue.go b/internal/commitquery/priority_queue.go deleted file mode 100644 index d6dbf54f..00000000 --- a/internal/commitquery/priority_queue.go +++ /dev/null @@ -1,68 +0,0 @@ -package commitquery - -import "container/heap" - -// priorityQueue orders internal nodes using one query context's comparator. -type priorityQueue struct { - ctx *Context - items []NodeIndex -} - -// newPriorityQueue builds one empty priority queue over one query context. -func newPriorityQueue(ctx *Context) *priorityQueue { - queue := &priorityQueue{ctx: ctx} - heap.Init(queue) - - return queue -} - -// Len reports the number of queued items. -func (queue *priorityQueue) Len() int { - return len(queue.items) -} - -// Less reports whether one heap slot sorts ahead of another. -func (queue *priorityQueue) Less(left, right int) bool { - return queue.ctx.Compare(queue.items[left], queue.items[right]) > 0 -} - -// Swap exchanges two heap slots. -func (queue *priorityQueue) Swap(left, right int) { - queue.items[left], queue.items[right] = queue.items[right], queue.items[left] -} - -// Push appends one heap element. -func (queue *priorityQueue) Push(item any) { - idx, ok := item.(NodeIndex) - if !ok { - panic("commitquery: heap push item is not a NodeIndex") - } - - queue.items = append(queue.items, idx) -} - -// Pop removes one heap element. -func (queue *priorityQueue) Pop() any { - last := len(queue.items) - 1 - item := queue.items[last] - queue.items = queue.items[:last] - - return item -} - -// PushNode inserts one internal node. -func (queue *priorityQueue) PushNode(idx NodeIndex) { - heap.Push(queue, idx) -} - -// PopNode removes the highest-priority internal node. -func (queue *priorityQueue) PopNode() NodeIndex { - item := heap.Pop(queue) - - idx, ok := item.(NodeIndex) - if !ok { - panic("commitquery: heap pop item is not a NodeIndex") - } - - return idx -} -- cgit v1.3.1-10-gc9f91