-
Notifications
You must be signed in to change notification settings - Fork 1
/
QueueTest.java
35 lines (25 loc) · 1.48 KB
/
QueueTest.java
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
import java.lang.reflect.Array;
/**
* Created by jkeys on 10/14/2015.
*/
public class QueueTest {
public static void main(String args[]) {
LinkedQueue<Integer> lq = new LinkedQueue<Integer>();
ArrayQueue<Integer> aq = new ArrayQueue<>();
System.out.println("Size of lq after instantiation: " + lq.size() + "\t\t\tSize of aq after instantiation: " + aq.size());
System.out.println("Front of lq after instantiation: " + lq.front() + "\t\tFront of lq after instantiation: " + aq.front());
System.out.println("lq.dequeue() empty queue, no effect if return null: " + lq.dequeue());
System.out.println("aq.dequeue() empty queue, no effect if return null: " + aq.dequeue());
for(int i = 1; i <= 10; i++) {
lq.enqueue(i);
aq.enqueue(i);
}
System.out.println("Size of lq after enqueue 1-10: " + lq.size() + "\t\t\tSize of aq after enqueue 1-10: " + aq.size());
System.out.println("Front of lq after enqueue 1-10: " + lq.front() + "\t\t\tFront of lq after enqueue 1-10: " + aq.front());
while(!lq.isEmpty()) {
System.out.println("lq.dequeue() == " + lq.dequeue() + "\t\t\taq.dequeue() == " + aq.dequeue());
}
System.out.println("Size of lq after lq.isEmpty(): " + lq.size() + "\t\t\tSize of aq after aq.isEmpty(): " + aq.size());
System.out.println("Front of lq after lq.isEmpty(): " + lq.front() + "\t\tFront of aq after aq.isEmpty(): " + aq.front());
}
}