T - type of elements in the list.
public class UniqueLinkedList<T> extends Object
Map lookup semantic, i.e.
Object.hashCode() and
Object.equals(Object) . This list supports insertion and removal at head and tail as well as a move-to-front and move-to-tail operation. The uniqueness of its elements is not explicitly enforced by the implementation, i.e. you have to expect strange results if adding the same element more than once. If you don't know whether an element is in the data structure because of your usage pattern anyway, use the
contains(Object) method to find out whether an element is already present.
| Constructor and Description |
|---|
UniqueLinkedList()
|
| Modifier and Type | Method and Description |
|---|---|
void |
addFirst(T element)
Add an element to the front of the list.
|
void |
addLast(T element)
Add an element to the end of the list.
|
void |
clear()
Remove all elements from the list.
|
boolean |
contains(T element)
Find out whether the specified element is currently contained within the list.
|
T |
getFirst()
Get the first element in the list.
|
T |
getLast()
Get the last element in the list.
|
void |
moveToFront(T element)
Move the denoted element to the front.
|
void |
moveToTail(T element)
Move the denoted element to the tail.
|
T |
removeFirst()
Remove the first element from the list.
|
T |
removeLast()
Remove the last element from the list.
|
int |
size()
Get the number of elements currently stored in this list.
|
public void addFirst(T element)
element - the element to add.
public void addLast(T element)
element - the element to add.
public int size()
public boolean contains(T element)
element - the element to check.
public T getFirst()
public T getLast()
public void clear()
public T removeFirst()
public T removeLast()
public void moveToFront(T element)
element - the element to move to the front.
public void moveToTail(T element)
element - the element to move to the tail.