You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The priority queue example is fine but very complex. I have heard of people copying and
pasting it (because it is unclear how to use the package otherwise) and having all the
code to maintain those index fields even if they were never used.
Two things to do:
1) Write a simple example. Make it first.
2) Make the complex example actually use the functionality the index field is allowing.
The text was updated successfully, but these errors were encountered:
The Push could be simplified by using append, as in the following code snippet:
func (pq *PriorityQueue) Push(x interface{}) {
item := x.(*Item)
item.index = len(*pq)
*pq = append(*pq, item)
}
The text was updated successfully, but these errors were encountered: