added a ForEach to priority queue to peek at contents

This commit is contained in:
Steve Dudenhoeffer 2022-10-15 10:25:40 -04:00
parent 92777666a9
commit 1f0c0866a7

View File

@ -77,3 +77,12 @@ func (q *PriorityQueue[T]) Clear() {
q.items = []*element[T]{} q.items = []*element[T]{}
} }
func (q *PriorityQueue[T]) ForEach(fn func(*T)) {
q.lock.RLock()
defer q.lock.RUnlock()
for _, v := range q.items {
fn(&v.value)
}
}