Package jltk.struc

Class Queue<ContentType>


  • public class Queue<ContentType>
    extends Object
    The generic class Queue is a linear data structure that stores elements in a FIFO (First In, First Out) order. Elements a added at the end of the queue and removed from the front.
    Version:
    23.08.2022
    Author:
    ms
    • Constructor Detail

      • Queue

        public Queue()
        Objects managed by this queue must be of type ContentType
    • Method Detail

      • enqueue

        public void enqueue​(ContentType pContent)
        The specified content of type ContentType is append to this queue. If pContent is null, othing happen.
        Parameters:
        pContent - The new content.
      • dequeue

        public void dequeue()
        Remove the first node from queue.
      • front

        public ContentType front()
        Return the content of the first node. If the queue is empty will return null.
        Returns:
        The content of the first node.
      • isEmpty

        public boolean isEmpty()
        Return true, if the queue is empty, else true,
        Returns:
        true, if this queue is empty, else false.
      • toString

        public String toString()
        Return the string representation of this queue. To represent an element, the toString() method pf the content is used. Each element is seperated by a semicolon. You can change the seperator by changing the attribut separator.
        Overrides:
        toString in class Object
        Returns:
        The string representation of this queue.