Package dsa
Interface Queue<T>
- Type Parameters:
T
- the type of items in the queue.
- All Superinterfaces:
Iterable<T>
- All Known Implementing Classes:
LinkedQueue
,ResizingArrayQueue
This interface specifies the API for the queue data structure.
-
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.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 interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
isEmpty
boolean isEmpty()Returnstrue
if this queue is empty, andfalse
otherwise.- Returns:
true
if this queue is empty, andfalse
otherwise.
-
size
int size()Returns the number of items in this queue.- Returns:
- number of items in this queue.
-
enqueue
Addsitem
to the end of this queue.- Parameters:
item
- the item.
-
peek
T peek()Returns the item at the front of this queue.- Returns:
- item at the front of this queue.
-
dequeue
T dequeue()Removes and returns the item at the front of this queue.- Returns:
- item at the front of this queue.
-
toString
String toString()Returns a string representation of this queue.
-