forked from hussien89aa/DataStructureAndAlgorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyQueue.java
More file actions
36 lines (30 loc) · 885 Bytes
/
myQueue.java
File metadata and controls
36 lines (30 loc) · 885 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
29
30
31
32
33
34
35
36
package collection.com;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
public class myQueue {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("basic queue");
Queue<Integer> q= new LinkedList<Integer> ();
q.add(15);
q.add(11);
q.add(10);
q.add(14);
System.out.println(q.poll());
System.out.println("prority queue");
PriorityQueue<Integer> qp= new PriorityQueue<Integer> ();
qp.add(15);
qp.add(11);
qp.add(10);
qp.add(14);
System.out.println(qp.poll());
System.out.println(qp.poll());
System.out.println("prority queue for students");
PriorityQueue<Student> pStudends= new PriorityQueue<Student> ();
pStudends.add(new Student("Hussein", 27));
pStudends.add(new Student("Jena", 2));
pStudends.add(new Student("Laya", 1));
System.out.println(pStudends.poll().name);
}
}