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:
java.io.Serializable
,java.lang.Cloneable
,java.lang.Iterable<T>
,java.util.Collection<T>
,java.util.List<T>
,java.util.RandomAccess
public class SortedList<T>
extends java.util.ArrayList<T>
Sorted list.
- 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(java.util.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
Modifier and Type Method Description boolean
add(T t)
Insert the new object at the position given by the Comparator.boolean
addAll(java.util.Collection<? extends T> externalObjs)
Insert the new objects at the position given by the Comparator.boolean
quickInsort(java.util.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 Details
-
SortedList
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
Copy constructor.- Parameters:
original
- the SortedList to copy
-
-
Method Details
-
add
Insert the new object at the position given by the Comparator. -
addAll
Insert the new objects at the position given by the Comparator. -
quickInsort
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
Sorts a single new object into this.- Parameters:
externalObj
- new object- Returns:
- true if this SortedList has been modified
-