Package de.tilman_neumann.util
Class SortedList<T>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.ArrayList<T>
-
- de.tilman_neumann.util.SortedList<T>
-
- Type Parameters:
T
- class of objects to be sorted
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<T>
,Collection<T>
,List<T>
,RandomAccess
public class SortedList<T> extends ArrayList<T>
Sorted list.- Author:
- Tilman Neumann
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class java.util.AbstractList
modCount
-
-
Constructor Summary
Constructors Constructor Description SortedList(SortedList<T> original)
Copy constructor.SortedList(Comparator<T> cmp, SortOrder sortOrder)
Complete constructor for a list sorted in ascending or descending order, where the comparison is done by an explicit constructor or the comparable capability of list elements.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(T t)
Insert the new object at the position given by the Comparator.boolean
addAll(Collection<? extends T> externalObjs)
Insert the new objects at the position given by the Comparator.boolean
quickInsort(Collection<? extends T> externalObjs)
Sort the given collection into this.boolean
quickInsort(T externalObj)
Sorts a single new object into this.-
Methods inherited from class java.util.ArrayList
add, addAll, clear, clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
-
Methods inherited from class java.util.AbstractCollection
containsAll, toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
-
Methods inherited from interface java.util.List
containsAll
-
-
-
-
Constructor Detail
-
SortedList
public SortedList(Comparator<T> cmp, SortOrder sortOrder)
Complete constructor for a list sorted in ascending or descending order, where the comparison is done by an explicit constructor or the comparable capability of list elements.- Parameters:
cmp
- External Comparator object or nullsortOrder
- ASCENDING or DESCENDING
-
SortedList
public SortedList(SortedList<T> original)
Copy constructor.- Parameters:
original
- the SortedList to copy
-
-
Method Detail
-
add
public boolean add(T t)
Insert the new object at the position given by the Comparator.
-
addAll
public boolean addAll(Collection<? extends T> externalObjs)
Insert the new objects at the position given by the Comparator.
-
quickInsort
public boolean quickInsort(Collection<? extends T> externalObjs)
Sort the given collection into this. The argument list should be sortable after the same criteria like this, using the same Comparator or Comparable interface.- Parameters:
externalObjs
- Collection of new objects- Returns:
- true if this SortedList has been modified
-
quickInsort
public boolean quickInsort(T externalObj)
Sorts a single new object into this.- Parameters:
externalObj
- new object- Returns:
- true if this SortedList has been modified
-
-