public class DoublyLinkedList<E> extends Object
Constructor and Description |
---|
DoublyLinkedList()
Constructs a new empty list.
|
Modifier and Type | Method and Description |
---|---|
void |
addFirst(E e)
Adds an element to the front of the list.
|
void |
addLast(E e)
Adds an element to the end of the list.
|
E |
first()
Returns (but does not remove) the first element of the list.
|
boolean |
isEmpty()
Tests whether the linked list is empty.
|
E |
last()
Returns (but does not remove) the last element of the list.
|
E |
removeFirst()
Removes and returns the first element of the list.
|
E |
removeLast()
Removes and returns the last element of the list.
|
int |
size()
Returns the number of elements in the linked list.
|
String |
toString()
Produces a string representation of the contents of the list.
|
public int size()
public boolean isEmpty()
public E first()
public E last()
public void addFirst(E e)
e
- the new element to addpublic void addLast(E e)
e
- the new element to addpublic E removeFirst()
public E removeLast()