Basic tasks with priority queues in java.
This commit is contained in:
parent
6b89476e26
commit
2edf415e2a
3 changed files with 64 additions and 0 deletions
23
current/algorithms/java/Queue.java
Normal file
23
current/algorithms/java/Queue.java
Normal file
|
@ -0,0 +1,23 @@
|
|||
import java.util.*;
|
||||
|
||||
public class Program {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
var arr = new ArrayList<Integer>();
|
||||
|
||||
arr.add(-4);
|
||||
|
||||
var pq = new PriorityQueue<Integer>();
|
||||
pq.add(1);
|
||||
pq.add(5);
|
||||
pq.add(-3);
|
||||
pq.add(-7);
|
||||
|
||||
System.out.printf("Hello World: %d\n", pq.remove());
|
||||
System.out.printf("Hello World: %d\n", pq.remove());
|
||||
System.out.printf("Hello World: %d\n", pq.remove());
|
||||
System.out.printf("Hello World: %d\n", pq.remove());
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue