diff --git a/priority_queue.go b/priority_queue.go index 6b58e43..eb9a501 100644 --- a/priority_queue.go +++ b/priority_queue.go @@ -76,9 +76,13 @@ func (h *PriorityQueue[T]) Range() []Item[T] { h.mu.RLock() defer h.mu.RUnlock() - var items []Item[T] + items := make([]Item[T], 0, h.internalHeap.Len()) for _, item := range h.internalHeap.items { - items = append(items, item) + items = append(items, Item[T]{ + Value: item.Value, + Priority: item.Priority, + index: item.index, + }) } return items