public class BasicLinkedList<T>
extends java.lang.Object
implements java.lang.Iterable<T>
| Constructor and Description |
|---|
BasicLinkedList()
Defines an empty linked list.
|
| Modifier and Type | Method and Description |
|---|---|
BasicLinkedList<T> |
addToEnd(T data)
Adds element to the end (tail) of the list.
|
BasicLinkedList<T> |
addToFront(T data)
Adds element to the front (head) of 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.
|
BasicLinkedList<T> |
removeAllInstances(T targetData)
Removes ALL instances of targetData from the list.
|
T |
retrieveFirstElement()
Removes and returns the first (head) element from the list.
|
T |
retrieveLastElement()
Removes and returns the last (tail) element from the list.
|
public BasicLinkedList()
public int getSize()
public BasicLinkedList<T> addToEnd(T data)
data - element to be addedpublic BasicLinkedList<T> addToFront(T data)
data - element to be addedpublic T getFirst()
public T getLast()
public T retrieveFirstElement()
public T retrieveLastElement()
public BasicLinkedList<T> removeAllInstances(T targetData)
targetData - element to be removedpublic java.util.Iterator<T> iterator()
iterator in interface java.lang.Iterable<T>