aima.core.util.datastructure.PriorityQueue Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aima-core Show documentation
Show all versions of aima-core Show documentation
AIMA-Java Core Algorithms from the book Artificial Intelligence a Modern Approach 3rd Ed.
package aima.core.util.datastructure;
import java.util.Collection;
import java.util.Comparator;
import java.util.SortedSet;
/**
* Artificial Intelligence A Modern Approach (3rd Edition): pg 80.
*
* The priority queue, which pops the element of the queue with the highest
* priority according to some ordering function.
*
* @author Ciaran O'Reilly
*/
public class PriorityQueue extends java.util.PriorityQueue implements
Queue {
private static final long serialVersionUID = 1;
public PriorityQueue() {
super();
}
public PriorityQueue(Collection c) {
super(c);
}
public PriorityQueue(int initialCapacity) {
super(initialCapacity);
}
public PriorityQueue(int initialCapacity, Comparator comparator) {
super(initialCapacity, comparator);
}
public PriorityQueue(PriorityQueue c) {
super(c);
}
public PriorityQueue(SortedSet c) {
super(c);
}
//
// START-Queue
public boolean isEmpty() {
return 0 == size();
}
public E pop() {
return poll();
}
public Queue insert(E element) {
if (offer(element)) {
return this;
}
return null;
}
// END-Queue
//
}