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>
An implementation of a double-linked list
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Appends data to the beginning of this list.void
Appends data to the end of this list.boolean
Check if the list contains specific datadeQueue()
Removes the element in the first positionvoid
Adds an element to the first positionfront()
Returns the data in the first positionboolean
isEmpty()
Returnstrue
if this list contains no elements.Deletes data from the begginning of this list.Deletes data from the end of this list.int
size()
Returns the current element count in this queue.
-
Field Details
-
size
int size -
head
-
tail
-
-
Constructor Details
-
MyDLList
public MyDLList()Creates a newMyDLList
object.
-
-
Method Details
-
isEmpty
public boolean isEmpty()Description copied from interface:QueueADT
Returnstrue
if this list contains no elements. -
addFirst
Appends data to the beginning of this list.- Parameters:
data
- The appended data.
-
addLast
Appends data to the end of this list.- Parameters:
data
- The appended data.
-
removeFirst
Deletes data from the begginning of this list.- Returns:
- The deleted data.
-
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. -
contains
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
Description copied from interface:QueueADT
Adds an element to the first position- Specified by:
enQueue
in interfaceQueueADT<E>
- Parameters:
element
- The element to be added- Throws:
NullPointerException
- If the element is null
-
deQueue
Description copied from interface:QueueADT
Removes the element in the first position- Specified by:
deQueue
in interfaceQueueADT<E>
- Returns:
- The head of this queue
- Throws:
NoSuchElementException
- If this queue is empty
-
front
Description copied from interface:QueueADT
Returns the data in the first position- Specified by:
front
in interfaceQueueADT<E>
- Returns:
- The head of this queue
- Throws:
NoSuchElementException
- if this queue is empty
-