public class DLinkedList<X>
extends java.lang.Object
Constructor and Description |
---|
DLinkedList() |
Modifier and Type | Method and Description |
---|---|
void |
add(X el)
Append a new element at the beginning of the list
|
void |
addFirst(X el)
Insert a new element at the beginning of the list
|
void |
addLast(X el)
Append a new element at the beginning of the list
|
void |
delete(DListNode<X> pNode)
Remove a given node from the list
|
DListNode<X> |
getFirst()
Return the first node of the list
The result is a null reference if the list is empty
|
DListNode<X> |
getLast()
Return the first node of the list
The result is a null reference if the list is empty
|
void |
insertAfter(DListNode<X> pNode,
X el)
Insert a new element after a given node in the list
|
void |
insertBefore(DListNode<X> pNode,
X el)
Insert a new element before a given node in the list
|
boolean |
isEmpty()
Check whether the list is empty
|
int |
size() |
java.lang.String |
toString()
Return a String representing the list
|
public int size()
public boolean isEmpty()
public DListNode<X> getFirst()
public DListNode<X> getLast()
public void addFirst(X el)
el
- the element to insertpublic void addLast(X el)
el
- the element to insertpublic void add(X el)
el
- the element to insertpublic void insertAfter(DListNode<X> pNode, X el)
el
- the element to insertnPnode
- the place where the element will be insertedpublic void insertBefore(DListNode<X> pNode, X el)
el
- the element to insertnPnode
- the place where the element will be insertedpublic void delete(DListNode<X> pNode)
nPnode
- the node to deletepublic java.lang.String toString()
toString
in class java.lang.Object