Added way to sort nodes

This commit is contained in:
Jsor
2014-02-04 23:01:28 -07:00
parent d53ec4c402
commit 26cf277e28

View File

@@ -142,6 +142,20 @@ func (pq *aStarPriorityQueue) Exists(id int) bool {
return ok return ok
} }
type denseNodeSorter []gr.Node
func (dns denseNodeSorter) Less(i, j int) bool {
return dns[i].ID() < dns[j].ID()
}
func (dns denseNodeSorter) Swap(i, j int) {
dns[i], dns[j] = dns[j], dns[i]
}
func (dns denseNodeSorter) Len() int {
return len(dns)
}
// General utility funcs // General utility funcs
// Rebuilds a path backwards from the goal. // Rebuilds a path backwards from the goal.