Constructor and Description |
---|
SinglyLinkedList()
Constructs an initially 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.
|
SinglyLinkedList<E> |
clone() |
boolean |
equals(Object o) |
E |
first()
Returns (but does not remove) the first element of the list
|
int |
hashCode() |
boolean |
isEmpty()
Tests whether the linked list is empty.
|
E |
last()
Returns (but does not remove) the last element of the list.
|
static void |
main(String[] args) |
E |
removeFirst()
Removes and returns the first 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 SinglyLinkedList<E> clone() throws CloneNotSupportedException
clone
in class Object
CloneNotSupportedException
public String toString()
public static void main(String[] args)