通过列表,我通常可以通过这样的方式找到元素:
int index = open.indexOf(object);
if(index != -1){
open.set(index, neighbour);
}
是否有优先级队列的替换/解决方法?
我有:
PriorityQueue<State> open = createQ();
答案 0 :(得分:0)
你可以这样做:
PriorityQueue<String> pq = new PriorityQueue<>();
pq.add("test1");
// removes object and return true if it was removed
if (pq.remove("test1")) {
// adds element in natural ordering
pq.add("test2");
}