50 likes | 134 Views
Ics202 Data Structures. Queueus. enqueue(1). enqueue (5). 3. 1. 4. 3. 1. 4. 1. 3. 1. 4. 1. 5. dequeue( ). dequeue( ). dequeue( ). 1. 5. 4. 1. 5. 1. 4. 1. 5.
E N D
Queueus enqueue(1) enqueue(5) 3 1 4 3 1 4 1 3 1 4 1 5 dequeue( ) dequeue( ) dequeue( ) 1 5 4 1 5 1 4 1 5
import ADTs.QueueAsArray;import ADTs.Visitor;import ADTs.IntegerPrintingVisitor;public class QueueAsArrayTest{ public static void main(String[] args) { // create an object of the class QueueAsArray called queue with size = 20. // create an object of the class QueueAsArray called queue2 with size = 20. // Using the enqueue() method, to insert (1,2,3) into the queue. System.out.println("Visiting Queue Elements Using Visitor"); Visitor v = newIntegerPrintingVisitor();queue.accept(v);
// Using the dequeue() method, to delete (1,2) from the queue. queue.showContent(); // Using the enqueue() method, to insert (1,2,3) into the queue2. System.out.println(); // Using the showContent () method to show the elements of queue2.if (queue.isEQ(queue2))System.out.println("queue equals queue2");else if (queue.isLT(queue2))System.out.println("queue less than queue2");else if (queue.isGT(queue2))System.out.println("queue greater than queue2"); }}
Using steps in Example 1 to test QueueAsLinkedList , Create your project with name (QueueAsLinkedListTest) . enqueue(1) enqueue(5) 3 1 4 3 1 4 1 3 1 4 1 5 dequeue( ) dequeue( ) dequeue( ) 1 5 4 1 5 1 4 1 5