Package utilities

Class MyDLList<E>

java.lang.Object
utilities.MyDLList<E>
Type Parameters:
E - The type of elements in this list.
All Implemented Interfaces:
QueueADT<E>

public class MyDLList<E> extends Object implements QueueADT<E>
An implementation of a double-linked list
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) MyDLLNode<E>
     
    (package private) int
     
    (package private) MyDLLNode<E>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new MyDLList object.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addFirst(E data)
    Appends data to the beginning of this list.
    void
    addLast(E data)
    Appends data to the end of this list.
    boolean
    contains(E data)
    Check if the list contains specific data
    Removes the element in the first position
    void
    enQueue(E element)
    Adds an element to the first position
    Returns the data in the first position
    boolean
    Returns true if this list contains no elements.
    Deletes data from the begginning of this list.
    Deletes data from the end of this list.
    int
    Returns the current element count in this queue.

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • MyDLList

      public MyDLList()
      Creates a new MyDLList object.
  • Method Details

    • isEmpty

      public boolean isEmpty()
      Description copied from interface: QueueADT
      Returns true if this list contains no elements.
      Specified by:
      isEmpty in interface QueueADT<E>
      Returns:
      true if this list contains no elements.
    • addFirst

      public void addFirst(E data)
      Appends data to the beginning of this list.
      Parameters:
      data - The appended data.
    • addLast

      public void addLast(E data)
      Appends data to the end of this list.
      Parameters:
      data - The appended data.
    • removeFirst

      public E removeFirst()
      Deletes data from the begginning of this list.
      Returns:
      The deleted data.
    • removeLast

      public E removeLast()
      Deletes data from the end of this list.
      Returns:
      The deleted data.
    • size

      public int size()
      Description copied from interface: QueueADT
      Returns the current element count in this queue.
      Specified by:
      size in interface QueueADT<E>
      Returns:
      The number of elements in this queue
    • contains

      public boolean contains(E data)
      Check if the list contains specific data
      Parameters:
      data - The data to check for.
      Returns:
      true if this list contains the specified data. Otherwise, false.
    • enQueue

      public void enQueue(E element) throws NullPointerException
      Description copied from interface: QueueADT
      Adds an element to the first position
      Specified by:
      enQueue in interface QueueADT<E>
      Parameters:
      element - The element to be added
      Throws:
      NullPointerException - If the element is null
    • deQueue

      public E deQueue() throws NoSuchElementException
      Description copied from interface: QueueADT
      Removes the element in the first position
      Specified by:
      deQueue in interface QueueADT<E>
      Returns:
      The head of this queue
      Throws:
      NoSuchElementException - If this queue is empty
    • front

      public E front() throws NoSuchElementException
      Description copied from interface: QueueADT
      Returns the data in the first position
      Specified by:
      front in interface QueueADT<E>
      Returns:
      The head of this queue
      Throws:
      NoSuchElementException - if this queue is empty