package simulator; import java.util.LinkedList; /** * This is a queue implemented with a linked list. As a regular queue, * its elements are ordered in a first-in-first-out(FIFO) manner. * * @author Gabriela Marcu * * @param */ public class MyQueue { LinkedList queue; public MyQueue() { queue = new LinkedList(); } public MyQueue(MyQueue other) { this.queue = new LinkedList(other.queue); } // Adds the element to the end of the queue, not allowing null elements. public void enqueue(E element) { queue.addLast(element); } // Returns and removes the first element of the queue. public E dequeue() { return queue.poll(); } // Returns true if the queue is empty, false otherwise. public boolean isEmpty() { return queue.size() == 0; } public MyQueue clone() { return new MyQueue(this); } }