-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathREADME
62 lines (46 loc) · 1.12 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
Priority Queue in Go
====================
This package provides a priority queue implementation and scaffold
interfaces.
Installation
------------
Use the `goinstall` tool:
$ goinstall github.com/nu7hatch/gopqueue
... or install it manually:
$ git clone git://github.com/nu7hatch/gopqueue.git
$ cd gopqueue
$ make install
Usage
-----
Here's trivial example of the fast queue usage:
package main
import pqueue "github.com/nu7hatch/gopqueue"
type Task struct {
Name string
priority int
}
func (t *Task) Less(other interface{}) bool {
return t.priority < other.(*Task).priority
}
func main() {
q := pqueue.New(0)
q.Enqueue(&Task{"one", 10})
q.Enqueue(&Task{"two", 2})
q.Enqueue(&Task{"three", 5})
q.Enqueue(&Task{"four", 7})
for i := 0; i < 4; i += 1 {
task := q.Dequeue()
println(task.(*Task).Name)
}
}
// Produces:
//
// two
// three
// four
// one
For more information and examples check the package documentation.
Copyright
---------
Copyright (C) 2011 by Krzysztof Kowalik <[email protected]>
See COPYING file for details.