Package dsa.lab03.solutions
Class LinkedQueue<Item>
java.lang.Object
dsa.lib.DSAObject
dsa.lab03.solutions.LinkedQueue<Item>
- Type Parameters:
Item- the item type
A linked queue.
Implements the queue interface by using a singly-linked list.
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct an empty linked queue.LinkedQueue(Item... items) Construct a linked queue containing the given items.LinkedQueue(Iterable<Item> items) Construct a linked queue containing the given items. -
Method Summary
Methods inherited from class dsa.lib.DSAObject
toDebugString, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface dsa.lib.DSAInterface
toDebugStringMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
LinkedQueue
public LinkedQueue()Construct an empty linked queue. -
LinkedQueue
Construct a linked queue containing the given items.- Parameters:
items- the items
-
LinkedQueue
Construct a linked queue containing the given items.- Parameters:
items- the items
-
-
Method Details
-
enqueue
Description copied from interface:QueueEnqueue (insert) the given item to the back. -
dequeue
Description copied from interface:QueueDequeue (remove and return) the given item from the front.- Specified by:
dequeuein interfaceQueue<Item>- Returns:
- the old front item
- Throws:
NoSuchElementException- if there's no first item to remove (i.e. if this is empty)
-
front
Description copied from interface:QueueGet the item at the front.- Specified by:
frontin interfaceQueue<Item>- Returns:
- the front item
- Throws:
NoSuchElementException- if there's no first item to retrieve (i.e. if this is empty)
-
size
public int size()Description copied from interface:ContainerGet the number of contained items. -
items
Description copied from interface:ContainerGet an iterable that yields each item once.
-