Package dsa
Interface Queue<Item>
-
- All Superinterfaces:
Iterable<Item>
- All Known Implementing Classes:
LinkedQueue
,ResizingArrayQueue
public interface Queue<Item> extends Iterable<Item>
This interface specifies the API for the queue data structure.
-
-
Method Summary
All Methods Instance Methods Abstract 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.Item
peek()
Returns the item at the front of this queue.int
size()
Returns the number of items in this queue.-
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
-
-
-
Method Detail
-
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
void enqueue(Item item)
Addsitem
to the end of this queue.- Parameters:
item
- the item.
-
peek
Item peek()
Returns the item at the front of this queue.- Returns:
- item at the front of this queue.
-
dequeue
Item dequeue()
Removes and returns the item at the front of this queue.- Returns:
- item at the front of this queue.
-
-