Documentation ¶
Overview ¶
Example (Usage) ¶
Insert some data into a priority queue and pop them out in prioritized order.
package main import ( "fmt" "github.com/Second-Earth/setchain/common/prque" ) func main() { // Define some data to push into the priority queue prio := []int64{77, 22, 44, 55, 11, 88, 33, 99, 0, 66} data := []string{"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"} // Create the priority queue and insert the prioritized data pq := prque.New(nil) for i := 0; i < len(data); i++ { pq.Push(data[i], prio[i]) } // Pop out the data and print them for !pq.Empty() { val, prio := pq.Pop() fmt.Printf("%d:%s ", prio, val) } }
Output: 99:seven 88:five 77:zero 66:nine 55:three 44:two 33:six 22:one 11:four 0:eight
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Prque ¶
type Prque struct {
// contains filtered or unexported fields
}
Priority queue data structure.
func (*Prque) Pop ¶
Pops the value with the greates priority off the stack and returns it. Currently no shrinking is done.
func (*Prque) PopItem ¶
func (p *Prque) PopItem() interface{}
Pops only the item from the queue, dropping the associated priority value.
Click to show internal directories.
Click to hide internal directories.