-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPriorityQueueTest.java
More file actions
28 lines (24 loc) · 846 Bytes
/
PriorityQueueTest.java
File metadata and controls
28 lines (24 loc) · 846 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package priorityQueue;
import java.time.LocalDate;
import java.util.PriorityQueue;
/**
* This program demonstrates the use of a priority queue.
*
* @author Cay Horstmann
* @version 1.02 2015-06-20
*/
public class PriorityQueueTest {
public static void main(String[] args) {
PriorityQueue<LocalDate> pq = new PriorityQueue<>();
pq.add(LocalDate.of(1906, 12, 9)); // G. Hopper
pq.add(LocalDate.of(1815, 12, 10)); // A. Lovelace
pq.add(LocalDate.of(1903, 12, 3)); // J. von Neumann
pq.add(LocalDate.of(1910, 6, 22)); // K. Zuse
System.out.println("Iterating over elements...");
for (LocalDate date : pq)
System.out.println(date);
System.out.println("Removing elements...");
while (!pq.isEmpty())
System.out.println(pq.remove());
}
}