From charlesreid1

No edit summary
m (Replacing charlesreid1.com:3000 with git.charlesreid1.com)
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
Two concrete priority queue classes and one abstract priority queue class implemented in Java. These classes can be found at git.charlesreid1.com.
=Links=


You can also find the Java Collections implementation of the Priority Queue class here: [http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/ff6c76f7733e/src/share/classes/java/util/PriorityQueue.java link]
==My Priority Queue API==


Two concrete priority queue classes and one abstract priority queue class implemented in Java. These classes can be found at git.charlesreid1.com: https://git.charlesreid1.com/cs/java/src/master/priority-queues/PriorityQueueBase.java
==Java Collections Priority Queue==
You can also find an implementation of a Priority Queue in the Java Collections API.
Source: http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/ff6c76f7733e/src/share/classes/java/util/PriorityQueue.java
Link: http://docs.oracle.com/javase/7/docs/api/java/util/PriorityQueue.html
=Code=


==Priority Queue Base Class==
==Priority Queue Base Class==


PriorityQueueBase class: https://charlesreid1.com:3000/cs/java/src/master/priority-queues/PriorityQueueBase.java
AbstractPriorityQueue class: https://git.charlesreid1.com/cs/java/src/master/priority-queues/AbstractPriorityQueue.java
 
This base class is an abstract class that defines a key-value item utility class, defines a few concrete methods, and defines several abstract methods.


This base class is an abstract class that defines a key-value item utility class, defines a few simple methods, and requires base classes to implement several other methods.
See [[Priority Queues/ADT]] for more code.


==Sorted Priority Queue==
==Sorted Priority Queue==


SortedPriorityQueue class: https://charlesreid1.com:3000/cs/java/src/master/priority-queues/SortedPriorityQueue.java
SortedPQ class: https://git.charlesreid1.com/cs/java/src/master/priority-queues/SortedPQ.java


This class implements a sorted priority queue using an O(N) insertion sort for each add operation (start from the back, swap your way toward the front) and a built-in Java Collections API Linked List (a doubly-linked list).  
This class implements a sorted priority queue using an O(N) insertion sort for each add operation (start from the back, swap your way toward the front) and a built-in Java Collections API Linked List (a doubly-linked list).  
Line 20: Line 33:
==Unsorted Priority Queue==
==Unsorted Priority Queue==


UnsortedPriorityQueue class: https://charlesreid1.com:3000/cs/java/src/master/priority-queues/UnsortedPriorityQueue.java
UnsortedPQ class: https://git.charlesreid1.com/cs/java/src/master/priority-queues/UnsortedPQ.java


This class implements an unsorted priority queue that does not keep track of the minimum element and must perform an O(N) sequential search for each removal operation.
This class implements an unsorted priority queue that does not keep track of the minimum element and must perform an O(N) sequential search for each removal operation.
Line 26: Line 39:
Fast add, slow remove.
Fast add, slow remove.


==Flags==
=Flags=


{{StacksQueuesFlag}}
{{PriorityQueuesFlag}}
[[Category:Queues]]
[[Category:Queues]]
[[Category:Priority Queues]]
[[Category:Priority Queues]]

Latest revision as of 03:44, 9 October 2019

Links

My Priority Queue API

Two concrete priority queue classes and one abstract priority queue class implemented in Java. These classes can be found at git.charlesreid1.com: https://git.charlesreid1.com/cs/java/src/master/priority-queues/PriorityQueueBase.java

Java Collections Priority Queue

You can also find an implementation of a Priority Queue in the Java Collections API.

Source: http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/ff6c76f7733e/src/share/classes/java/util/PriorityQueue.java

Link: http://docs.oracle.com/javase/7/docs/api/java/util/PriorityQueue.html

Code

Priority Queue Base Class

AbstractPriorityQueue class: https://git.charlesreid1.com/cs/java/src/master/priority-queues/AbstractPriorityQueue.java

This base class is an abstract class that defines a key-value item utility class, defines a few concrete methods, and defines several abstract methods.

See Priority Queues/ADT for more code.

Sorted Priority Queue

SortedPQ class: https://git.charlesreid1.com/cs/java/src/master/priority-queues/SortedPQ.java

This class implements a sorted priority queue using an O(N) insertion sort for each add operation (start from the back, swap your way toward the front) and a built-in Java Collections API Linked List (a doubly-linked list).

Slow add, fast remove.

Unsorted Priority Queue

UnsortedPQ class: https://git.charlesreid1.com/cs/java/src/master/priority-queues/UnsortedPQ.java

This class implements an unsorted priority queue that does not keep track of the minimum element and must perform an O(N) sequential search for each removal operation.

Fast add, slow remove.

Flags