Package dsa
Class ResizingArrayQueue<Item>
- java.lang.Object
-
- dsa.ResizingArrayQueue<Item>
-
-
Constructor Summary
Constructors Constructor Description ResizingArrayQueue()
Constructs an empty queue.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Item
dequeue()
Removes and returns the item at the front of this queue.void
enqueue(Item item)
Addsitem
to the end of this queue.boolean
isEmpty()
Returnstrue
if this queue is empty, andfalse
otherwise.Iterator<Item>
iterator()
Returns an iterator to iterate over the items in this queue in FIFO order.static void
main(String[] args)
Unit tests the data type.Item
peek()
Returns the item at the front of this queue.int
size()
Returns the number of items in this queue.String
toString()
Returns a string representation of this queue.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
isEmpty
public boolean isEmpty()
Description copied from interface:Queue
Returnstrue
if this queue is empty, andfalse
otherwise.
-
size
public int size()
Description copied from interface:Queue
Returns the number of items in this queue.
-
enqueue
public void enqueue(Item item)
Description copied from interface:Queue
Addsitem
to the end of this queue.
-
peek
public Item peek()
Description copied from interface:Queue
Returns the item at the front of this queue.
-
dequeue
public Item dequeue()
Description copied from interface:Queue
Removes and returns the item at the front of this queue.
-
iterator
public Iterator<Item> iterator()
Returns an iterator to iterate over the items in this queue in FIFO order.
-
toString
public String toString()
Returns a string representation of this queue.
-
main
public static void main(String[] args)
Unit tests the data type.- Parameters:
args
- the command-line arguments.
-
-