E
- the type of element held in this queuepublic class Queue<E> extends Object
Constructor and Description |
---|
Queue()
Creates an empty queue (size is zero).
|
Modifier and Type | Method and Description |
---|---|
E |
dequeue()
Dequeue an element.
|
void |
enqueue(E element)
Enqueue an element.
|
boolean |
equals(Object obj)
Compares the specified object to this queue for equality.
|
int |
hashCode()
Returns a hash code for this queue.
|
boolean |
isEmpty()
Returns true if this queue is empty, and false otherwise.
|
E |
peek()
Return the element at the front of the queue without dequeuing the element.
|
int |
size()
Returns the number of elements in this queue.
|
String |
toString()
Returns a string representation of this queue.
|
public void enqueue(E element)
element
- the element to add to the back of the queuepublic E dequeue()
NoSuchElementException
- if the queue is emptypublic E peek()
NoSuchElementException
- if the queue is emptypublic int size()
public boolean isEmpty()
public int hashCode()
hashCode
in class Object
Object.hashCode()
public boolean equals(Object obj)
equals
in class Object
Object.equals(java.lang.Object)
obj
- the object to compare to this queue for equalitypublic String toString()
toString
in class Object
Object.toString()