Package com.javaholics
Class LinkedQueue<T>
java.lang.Object
com.javaholics.LinkedQueue<T>
- Type Parameters:
T
- The type of data stored in the queue.
- All Implemented Interfaces:
QueueInterface<T>
Represents a queue data structure using a linked list.
This class implements the QueueInterface and provides methods for
adding, removing, and checking the front of the queue.
This class uses a linked list to store the data in the queue.
- Author:
- Lindsay Kislingbury, Lea Wiranatha
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Removes all entries from this queue.boolean
Checks whether this queue contains the given entry.dequeue()
Removes and returns the entry at the front of this queue.void
Adds a new entry to the back of this queue.getFront()
Retrieves the entry at the front of this queue.boolean
isEmpty()
Checks whether this queue is empty.
-
Constructor Details
-
LinkedQueue
public LinkedQueue()Constructs a new, empty queue.
-
-
Method Details
-
enqueue
Adds a new entry to the back of this queue.- Specified by:
enqueue
in interfaceQueueInterface<T>
- Parameters:
newEntry
- The entry to add to the queue.
-
dequeue
Removes and returns the entry at the front of this queue.- Specified by:
dequeue
in interfaceQueueInterface<T>
- Returns:
- The entry at the front of the queue.
-
getFront
Retrieves the entry at the front of this queue.- Specified by:
getFront
in interfaceQueueInterface<T>
- Returns:
- The entry at the front of the queue.
-
isEmpty
public boolean isEmpty()Checks whether this queue is empty.- Specified by:
isEmpty
in interfaceQueueInterface<T>
- Returns:
- True if the queue is empty, false otherwise.
-
clear
public void clear()Removes all entries from this queue. The queue will be empty after this method returns.- Specified by:
clear
in interfaceQueueInterface<T>
-
contains
Checks whether this queue contains the given entry.- Parameters:
entry
- The entry to check for in the queue.- Returns:
- True if the queue contains the entry, false otherwise.
-