@@ -107,7 +107,7 @@ func (items *priorityItems) push(item Item) {
107107type PriorityQueue struct {
108108 waiters waiters
109109 items priorityItems
110- itemMap map [Item ]bool
110+ itemMap map [Item ]struct {}
111111 lock sync.Mutex
112112 disposeLock sync.Mutex
113113 disposed bool
@@ -126,8 +126,8 @@ func (pq *PriorityQueue) Put(items ...Item) error {
126126 }
127127
128128 for _ , item := range items {
129- if ok := pq .itemMap [item ]; ! ok {
130- pq .itemMap [item ] = true
129+ if _ , ok := pq .itemMap [item ]; ! ok {
130+ pq .itemMap [item ] = struct {}{}
131131 pq .items .push (item )
132132 }
133133 }
@@ -170,7 +170,7 @@ func (pq *PriorityQueue) Get(number int) ([]Item, error) {
170170 // Remove references to popped items.
171171 deleteItems := func (items []Item ) {
172172 for _ , item := range items {
173- pq .itemMap [ item ] = false
173+ delete ( pq .itemMap , item )
174174 }
175175 }
176176
@@ -257,6 +257,6 @@ func (pq *PriorityQueue) Dispose() {
257257func NewPriorityQueue (hint int ) * PriorityQueue {
258258 return & PriorityQueue {
259259 items : make (priorityItems , 0 , hint ),
260- itemMap : make (map [Item ]bool , hint ),
260+ itemMap : make (map [Item ]struct {} , hint ),
261261 }
262262}
0 commit comments