-
Couldn't load subscription status.
- Fork 6
Simple priority queue in Go
License
Couldn't load subscription status.
nu7hatch/gopqueue
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
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.
About
Simple priority queue in Go
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published