public class BasicDoubleLinkedList<T>
extends java.lang.Object
implements java.lang.Iterable<T>
| Constructor and Description |
|---|
BasicDoubleLinkedList()
Defines an empty linked list.
|
| Modifier and Type | Method and Description |
|---|---|
BasicDoubleLinkedList<T> |
add(int index,
T data)
Adds element at the index position in the list.
|
BasicDoubleLinkedList<T> |
addToEnd(T data)
Adds element to the end of the list.
|
BasicDoubleLinkedList<T> |
addToFront(T data)
Adds element to the front of the list.
|
T |
get(int index)
Returns but does not remove the element at the index position in the list.
|
T |
getFirst()
Returns but does not remove the first element from the list.
|
T |
getLast()
Returns but does not remove the last element from the list.
|
int |
getSize()
Notice you must not traverse the list to compute the size.
|
java.util.Iterator<T> |
iterator()
This method must be implemented using an anonymous inner class that
defines the iterator.
|
BasicDoubleLinkedList<T> |
remove(T targetData,
java.util.Comparator<T> comparator)
Removes ALL instances of targetData from the list.
|
T |
retrieve(int index)
Removes and returns the element at the index position from the list (zero indexed).
|
T |
retrieveFirstElement()
Removes and returns the first element from the list.
|
T |
retrieveLastElement()
Removes and returns the last element from the list.
|
public BasicDoubleLinkedList()
public int getSize()
public BasicDoubleLinkedList<T> addToEnd(T data)
data - public BasicDoubleLinkedList<T> addToFront(T data)
data - public BasicDoubleLinkedList<T> add(int index, T data)
data - public T getFirst()
public T getLast()
public T get(int index)
public T retrieveFirstElement()
public T retrieveLastElement()
public T retrieve(int index)
public BasicDoubleLinkedList<T> remove(T targetData, java.util.Comparator<T> comparator)
targetData - comparator - public java.util.Iterator<T> iterator()
iterator in interface java.lang.Iterable<T>