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

      public 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.
      Parameters:
      cmp - External Comparator object or null
      sortOrder - ASCENDING or DESCENDING
    • SortedList

      public SortedList​(SortedList<T> original)
      Copy constructor.
      Parameters:
      original - the SortedList to copy
  • Method Details

    • add

      public boolean add​(T t)
      Insert the new object at the position given by the Comparator.
      Specified by:
      add in interface java.util.Collection<T>
      Specified by:
      add in interface java.util.List<T>
      Overrides:
      add in class java.util.ArrayList<T>
    • addAll

      public boolean addAll​(java.util.Collection<? extends T> externalObjs)
      Insert the new objects at the position given by the Comparator.
      Specified by:
      addAll in interface java.util.Collection<T>
      Specified by:
      addAll in interface java.util.List<T>
      Overrides:
      addAll in class java.util.ArrayList<T>
    • quickInsort

      public boolean quickInsort​(java.util.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