Interface SortedCollection<E>

Type Parameters:
E - The element type.
All Superinterfaces:
Cloneable, Collection<E>, Iterable<E>, OrderedCollection<E>
All Known Subinterfaces:
ModifiableSortedCollection<E>
All Known Implementing Classes:
ModifiableSortedTreeCollection, SortedArrayCollection, SortedTreeCollection

public interface SortedCollection<E> extends OrderedCollection<E>
Interface defining the signature for all sorted collections.
  • Method Details

    • empty

      static <F> SortedCollection<F> empty(Comparator<? super F> comparator)
      Returns a new empty sorted collection.
      Type Parameters:
      F - The element type.
      Parameters:
      comparator - The comparator by which to sort the elements.
      Returns:
      A new empty sorted collection.
    • of

      static <F> SortedCollection<F> of(Comparator<? super F> comparator, Collection<? extends F> collection)
      Returns a new sorted collection cloned from the provided collection.
      Type Parameters:
      F - The element type.
      Parameters:
      comparator - The comparator by which to sort the elements.
      collection - The original collection.
      Returns:
      A new sorted collection cloned from the provided collection.
    • of

      static <F> SortedCollection<F> of(Comparator<? super F> comparator, OrderedCollection<? extends F> collection, int fromIndex, int toIndex)
      Returns a new sorted collection cloned from a range in the provided ordered collection.
      Type Parameters:
      F - The element type.
      Parameters:
      comparator - The comparator by which to sort the elements.
      collection - The original ordered collection.
      fromIndex - The index of the first element to be included in the new ordered collection.
      toIndex - The index of the first element not to be included in the new ordered collection.
      Returns:
      A new sorted collection cloned from a range in the provided ordered collection.
    • of

      static <F> SortedCollection<F> of(Comparator<? super F> comparator, F... elements)
      Returns a new sorted collection with the specified elements.
      Type Parameters:
      F - The element type.
      Parameters:
      comparator - The comparator by which to sort the elements.
      elements - The elements for the new sorted collection.
      Returns:
      A new sorted collection with the specified elements.
    • of

      static <F> SortedCollection<F> of(Collection.ElementCardinality elementCardinality, Comparator<? super F> comparator, F... elements)
      Returns a new sorted collection with the specified element cardinality and the elements.
      Type Parameters:
      F - The element type.
      Parameters:
      elementCardinality - The element cardinality.
      comparator - The comparator by which to sort the elements.
      elements - The elements for the new sorted collection.
      Returns:
      A new sorted collection with the specified element cardinality and the elements.
    • of

      static <F> SortedCollection<F> of(SortedCollection<F> collection)
      Returns a new sorted collection cloned from the provided sorted collection.
      Type Parameters:
      F - The element type.
      Parameters:
      collection - The original sorted collection.
      Returns:
      A new sorted collection cloned from the provided sorted collection.
    • of

      static <F> SortedCollection<F> of(SortedCollection<F> collection, Range<F> range)
      Returns a new sorted collection cloned from the provided sorted collection.
      Type Parameters:
      F - The element type.
      Parameters:
      collection - The original sorted collection.
      range - The range.
      Returns:
      A new sorted collection cloned from the provided sorted collection.
    • getComparator

      Comparator<? super E> getComparator()
      Returns the comparator sorting this collection.
      Returns:
      The comparator sorting this collection
    • getGreaterThan

      E getGreaterThan(E element) throws IndexOutOfBoundsException
      Returns the least element in this collection greater than the provided element.
      Parameters:
      element - The value to match.
      Returns:
      The least element in this collection greater than the provided element.
      Throws:
      IndexOutOfBoundsException - Thrown if the collection doesn't contain an element that's greater than the provided element, or the collection is empty.
    • getGreaterThanOrEqualTo

      E getGreaterThanOrEqualTo(E element) throws IndexOutOfBoundsException
      Returns the least element in this collection greater than or equal to the provided element.
      Parameters:
      element - The value to match.
      Returns:
      The least element in this collection greater than or equal to the provided element.
      Throws:
      IndexOutOfBoundsException - Thrown if the collection doesn't contain an element that's greater than or equal to the provided element, or the collection is empty.
    • getGreatest

      default E getGreatest() throws IndexOutOfBoundsException
      Returns the greatest element in the collection.
      Returns:
      The greatest element in the collection.
      Throws:
      IndexOutOfBoundsException - Thrown if the collection is empty.
    • getLeast

      default E getLeast() throws IndexOutOfBoundsException
      Returns the least element in the collection.
      Returns:
      The least element in the collection.
      Throws:
      IndexOutOfBoundsException - Thrown if the collection is empty.
    • getLessThan

      E getLessThan(E element) throws IndexOutOfBoundsException
      Returns the greatest element in this collection less than the provided element.
      Parameters:
      element - The value to match.
      Returns:
      The greatest element in this collection less than the provided element.
      Throws:
      IndexOutOfBoundsException - Thrown if the collection doesn't contain an element that's less than the provided element, or the collection is empty.
    • getLessThanOrEqualTo

      E getLessThanOrEqualTo(E element) throws IndexOutOfBoundsException
      Returns the greatest element in this collection less than or equal to the provided element.
      Parameters:
      element - The value to match.
      Returns:
      The greatest element in this collection less than or equal to the provided element.
      Throws:
      IndexOutOfBoundsException - Thrown if the collection doesn't contain an element that's less than or equal to the provided element, or the collection is empty.