public class LinkedQueue<E> extends java.lang.Object implements QueueInterface<E>
| Modifier and Type | Field and Description |
|---|---|
(package private) Node<E> |
back |
(package private) Node<E> |
front |
(package private) int |
numElements |
| Constructor and Description |
|---|
LinkedQueue() |
| Modifier and Type | Method and Description |
|---|---|
E |
dequeue()
Retrieves and removes the element at the head of this queue.
|
E |
dequeue(int index)
Retrieves and removes the element at the specified index.
|
void |
enqueue(E e)
Adds the specified element into the stack if it is possible to do so immediately without
violating capacity restrictions, otherwise, throwing an IllegalStateException
if no space is currently available or NullPointerException if the specified element is null.
|
boolean |
isEmpty()
This method is called to determine if the queue is empty.
|
java.util.Iterator<E> |
iterator() |
E |
peek()
Retrieves, but does not remove, the head of this queue.
|
void |
removeAll()
Removes all elements from the queue.
|
int |
size()
This method is called to obtain the count of elements in the list.
|
public java.util.Iterator<E> iterator()
iterator in interface java.lang.Iterable<E>public boolean isEmpty()
QueueInterfaceisEmpty in interface QueueInterface<E>public int size()
QueueInterfacesize in interface QueueInterface<E>public void enqueue(E e) throws java.lang.IllegalStateException, java.lang.NullPointerException
QueueInterfaceenqueue in interface QueueInterface<E>e - The element to add.java.lang.IllegalStateException - If the element cannot be added at this time due to capacity restrictions.java.lang.NullPointerException - If the specified element being added is null.public E peek()
QueueInterfacepeek in interface QueueInterface<E>public E dequeue()
QueueInterfacedequeue in interface QueueInterface<E>public E dequeue(int index) throws java.util.NoSuchElementException
QueueInterfacedequeue in interface QueueInterface<E>index - The index of the element to be removed.java.util.NoSuchElementException - If the specified index is invalid.public void removeAll()
QueueInterfaceremoveAll in interface QueueInterface<E>