How to use priority queues in Scala?

后端 未结 2 1741
温柔的废话
温柔的废话 2021-02-07 07:53

I am trying to implement A* search in Scala (version 2.10), but I\'ve ran into a brick wall - I can\'t figure out how to use Scala\'s Priority Queue. It seems like a simple task

2条回答
  •  难免孤独
    2021-02-07 08:47

    Indeed, there is no implicit ordering on pairs of integers (a, b). What would it be? Perhaps they are both positive and you can use (a - 1.0/b)? Or they are not, and you can use, what, (a + atan(b/pi))? If you have an ordering in mind, you can consider wrapping your pairs in a type that has your ordering.

提交回复
热议问题