package cse1030.datastructures; import java.util.LinkedList; /** * A simple queue implementation supporting enqueue, dequeue, * and isEmpty operations. * * @author CSE1030 * * @param the type of element held by this queue */ public class Queue { private LinkedList q; /** * Create an empty queue. */ public Queue() { this.q = new LinkedList(); } /** * Add an element to the back of the queue. * * @param element the element to add to the back of the queue */ public void enqueue(E element) { this.q.addLast(element); } /** * Remove the front element of the queue. The element is returned * to the client. * * @return the element that was removed from the front of the queue */ public E dequeue() { return this.q.removeFirst(); } /** * Returns true if this queue contains no elements. * * @return true if this queue contains no elements */ public boolean isEmpty() { return this.q.isEmpty(); } }