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>

public class LinkedQueue<T> extends Object implements 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

    Constructors
    Constructor
    Description
    Constructs a new, empty queue.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Removes all entries from this queue.
    boolean
    contains(T entry)
    Checks whether this queue contains the given entry.
    Removes and returns the entry at the front of this queue.
    void
    enqueue(T newEntry)
    Adds a new entry to the back of this queue.
    Retrieves the entry at the front of this queue.
    boolean
    Checks whether this queue is empty.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LinkedQueue

      public LinkedQueue()
      Constructs a new, empty queue.
  • Method Details

    • enqueue

      public void enqueue(T newEntry)
      Adds a new entry to the back of this queue.
      Specified by:
      enqueue in interface QueueInterface<T>
      Parameters:
      newEntry - The entry to add to the queue.
    • dequeue

      public T dequeue()
      Removes and returns the entry at the front of this queue.
      Specified by:
      dequeue in interface QueueInterface<T>
      Returns:
      The entry at the front of the queue.
    • getFront

      public T getFront()
      Retrieves the entry at the front of this queue.
      Specified by:
      getFront in interface QueueInterface<T>
      Returns:
      The entry at the front of the queue.
    • isEmpty

      public boolean isEmpty()
      Checks whether this queue is empty.
      Specified by:
      isEmpty in interface QueueInterface<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 interface QueueInterface<T>
    • contains

      public boolean contains(T entry)
      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.