Package dsa
Class ResizingArrayQueue<T>
java.lang.Object
dsa.ResizingArrayQueue<T>
- Type Parameters:
T
- the type of items in the queue.
This data type provides an implementation of the Queue API, using an array as the underlying data structure.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondequeue()
Removes and returns the item at the front of this queue.void
Addsitem
to the end of this queue.boolean
isEmpty()
Returnstrue
if this queue is empty, andfalse
otherwise.iterator()
Returns an iterator to iterate over the items in this queue in FIFO order.static void
Unit tests the data type.peek()
Returns the item at the front of this queue.int
size()
Returns the number of items in this queue.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
-
Constructor Details
-
ResizingArrayQueue
public ResizingArrayQueue()Constructs an empty queue.
-
-
Method Details
-
isEmpty
public boolean isEmpty()Returnstrue
if this queue is empty, andfalse
otherwise. -
size
public int size()Returns the number of items in this queue. -
enqueue
Addsitem
to the end of this queue. -
peek
Returns the item at the front of this queue. -
dequeue
Removes and returns the item at the front of this queue. -
toString
Returns a string representation of this queue. -
iterator
Returns an iterator to iterate over the items in this queue in FIFO order. -
main
Unit tests the data type.- Parameters:
args
- the command-line arguments.
-