public class SortedList<T>
extends java.util.LinkedList<T>
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
ascending
The ordering direction of the list.
|
protected java.util.Comparator<? super T> |
comp
The comparator to use (if any).
|
| Constructor and Description |
|---|
SortedList()
Constructs an empty list with ascending order.
|
SortedList(boolean ascending)
Constructs an empty list with given order.
|
SortedList(java.util.Comparator<? super T> comp,
boolean ascending)
Constructs an empty list with given order.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(int index,
T element)
Inserts the specified element at the specified position in this list.
|
boolean |
add(T o)
Appends the specified element to the end of this list.
|
boolean |
addAll(java.util.Collection<? extends T> c)
Appends all of the elements in the specified collection to the end of
this list, in the order that they are returned by the specified
collection's iterator.
|
boolean |
addAll(int index,
java.util.Collection<? extends T> c)
Inserts all of the elements in the specified collection into this
list, starting at the specified position.
|
void |
addFirst(T o)
Inserts the given element at the beginning of this list.
|
void |
addLast(T o)
Appends the given element to the end of this list.
|
protected int |
compare(T o1,
T o2)
Compare two elements.
|
int |
insertElement(int index,
T obj)
Insert an element into the list.
|
clear, clone, contains, descendingIterator, element, get, getFirst, getLast, indexOf, lastIndexOf, listIterator, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, pop, push, remove, remove, remove, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence, set, size, spliterator, toArray, toArrayequals, hashCode, listIterator, removeRange, subListcontainsAll, isEmpty, removeAll, retainAll, toStringfinalize, getClass, notify, notifyAll, wait, wait, waitprotected boolean ascending
protected java.util.Comparator<? super T> comp
public SortedList()
public SortedList(boolean ascending)
ascending - True, if the list should sort ascending.public SortedList(java.util.Comparator<? super T> comp, boolean ascending)
comp - A comparator to use for comparing elements.ascending - True, if the list shoudl sort ascending.public void addFirst(T o)
public void addLast(T o)
addLast in interface java.util.Deque<T>addLast in class java.util.LinkedList<T>o - the element to be inserted at the end of this list.public boolean add(T o)
add in interface java.util.Collection<T>add in interface java.util.Deque<T>add in interface java.util.List<T>add in interface java.util.Queue<T>add in class java.util.LinkedList<T>o - element to be appended to this list.public boolean addAll(java.util.Collection<? extends T> c)
addAll in interface java.util.Collection<T>addAll in interface java.util.List<T>addAll in class java.util.LinkedList<T>c - the elements to be inserted into this list.java.lang.NullPointerException - if the specified collection is null.public boolean addAll(int index,
java.util.Collection<? extends T> c)
addAll in interface java.util.List<T>addAll in class java.util.LinkedList<T>index - index at which to insert first element
from the specified collection.c - elements to be inserted into this list.java.lang.IndexOutOfBoundsException - if the specified index is out of
range (
java.lang.NullPointerException - if the specified collection is null.public void add(int index,
T element)
public int insertElement(int index,
T obj)
index - The index where to start insertion.obj - The element to insert.