Method
ChangePriority
(val interface{}, priority int)
Source from the content-addressed store, hash-verified
| 50 | } |
| 51 | |
| 52 | func (pq *PQ) ChangePriority(val interface{}, priority int) { |
| 53 | var storage = queue.New() |
| 54 | |
| 55 | popped := pq.Extract() |
| 56 | |
| 57 | for val != popped.Value { |
| 58 | if pq.Len() == 0 { |
| 59 | panic("Item not found") |
| 60 | } |
| 61 | |
| 62 | storage.Push(popped) |
| 63 | popped = pq.Extract() |
| 64 | } |
| 65 | |
| 66 | popped.Priority = priority |
| 67 | pq.data.Insert(popped) |
| 68 | |
| 69 | for storage.Len() > 0 { |
| 70 | pq.data.Insert(storage.Shift().(heap.Item)) |
| 71 | } |
| 72 | } |