java.lang.Objectcom.fun.tips.DoublyLinkedList<T>
T - The type of the data items stored in the listpublic class DoublyLinkedList<T>
A doubly linked list implementation
| Constructor Summary | |
|---|---|
DoublyLinkedList()
|
|
| Method Summary | |
|---|---|
void |
appendElement(T e)
Append an element to the list |
DoublyLinkedList<T> |
clone()
Clone the list (data items will not be cloned) |
T |
getElementAt(int index)
Get the element at the specified index |
T |
getFirstElement()
Get the first element of the list |
T |
getLastElement()
Get the last element of the list |
int |
getSize()
Get the size of the list |
boolean |
insertElementAt(T e,
int index)
Insert an element at the specified index |
boolean |
isEmpty()
Check if the list is empty |
java.util.Iterator<T> |
iterator()
|
static void |
main(java.lang.String[] args)
|
void |
prependElement(T e)
Prepend an element to the list |
boolean |
removeElementAt(int index)
Remove the element at the given index |
boolean |
removeFirstElement()
Remove the first element from the list |
boolean |
removeLastElement()
Remove the last element from the list |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public DoublyLinkedList()
| Method Detail |
|---|
public void appendElement(T e)
e - element to appendpublic DoublyLinkedList<T> clone()
clone in class java.lang.Objectpublic T getElementAt(int index)
index - index of the element
public T getFirstElement()
public T getLastElement()
public int getSize()
public boolean insertElementAt(T e,
int index)
e - Elemenent to insertindex - index at which the element should be inserted (in range [0..size()])
public boolean isEmpty()
public java.util.Iterator<T> iterator()
iterator in interface java.lang.Iterable<T>public static void main(java.lang.String[] args)
public void prependElement(T e)
e - element to prependpublic boolean removeElementAt(int index)
index - index of the element to remove ([0..size()-1])
public boolean removeFirstElement()
public boolean removeLastElement()
public java.lang.String toString()
toString in class java.lang.Object