Package com.zybooks.dsaj.stackqueue
Class LinkedQueue<E>
java.lang.Object
com.zybooks.dsaj.stackqueue.LinkedQueue<E>
- Type Parameters:
E
- the element type
- All Implemented Interfaces:
Queue<E>
Realization of a FIFO queue as an adaptation of a SinglyLinkedList.
All operations are performed in constant time.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondequeue()
Removes and returns the first element of the queue.void
Adds an element at the rear of the queue.first()
Returns, but does not remove, the first element of the queue.boolean
isEmpty()
Tests whether the queue is empty.int
size()
Returns the number of elements in the queue.toString()
Produces a string representation of the contents of the queue.
-
Constructor Details
-
LinkedQueue
public LinkedQueue()Constructs an initially empty queue.
-
-
Method Details
-
size
public int size()Returns the number of elements in the queue. -
isEmpty
public boolean isEmpty()Tests whether the queue is empty. -
enqueue
Adds an element at the rear of the queue. -
first
Returns, but does not remove, the first element of the queue. -
dequeue
Removes and returns the first element of the queue. -
toString
Produces a string representation of the contents of the queue. (from front to back). This exists for debugging purposes only.
-