public class Queue<Item> extends Object implements Iterable<Item>
All queue operations except iteration are constant time.
For additional documentation, see Section 4.3 of Introduction to Programming in Java: An Interdisciplinary Approach by Robert Sedgewick and Kevin Wayne.
| Constructor and Description |
|---|
Queue()
Create an empty queue.
|
| Modifier and Type | Method and Description |
|---|---|
Item |
dequeue()
Remove and return the item on the queue least recently added.
|
void |
enqueue(Item item)
Add the item to the queue.
|
boolean |
isEmpty()
Is the queue empty?
|
Iterator<Item> |
iterator()
Return an iterator that iterates over the items on the queue in FIFO order.
|
int |
length()
Return the number of items in the queue.
|
static void |
main(String[] args)
A test client.
|
Item |
peek()
Return the item least recently added to the queue.
|
int |
size()
Return the number of items in the queue.
|
String |
toString()
Return string representation.
|
public boolean isEmpty()
public int size()
public int length()
public Item peek()
public void enqueue(Item item)
public Item dequeue()
public Iterator<Item> iterator()
public static void main(String[] args)
Copyright © 2014. All Rights Reserved.