added a ForEach to priority queue to peek at contents
This commit is contained in:
parent
92777666a9
commit
1f0c0866a7
@ -77,3 +77,12 @@ func (q *PriorityQueue[T]) Clear() {
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user