Package net.filipvanlaenen.kolektoj
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
Interface defining the signature for all sorted collections.
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.filipvanlaenen.kolektoj.Collection
Collection.ElementCardinality -
Method Summary
Modifier and TypeMethodDescriptionstatic <F> SortedCollection<F>empty(Comparator<? super F> comparator) Returns a new empty sorted collection.Comparator<? super E>Returns the comparator sorting this collection.getGreaterThan(E element) Returns the least element in this collection greater than the provided element.getGreaterThanOrEqualTo(E element) Returns the least element in this collection greater than or equal to the provided element.default EReturns the greatest element in the collection.default EgetLeast()Returns the least element in the collection.getLessThan(E element) Returns the greatest element in this collection less than the provided element.getLessThanOrEqualTo(E element) Returns the greatest element in this collection less than or equal to the provided element.static <F> SortedCollection<F>of(Comparator<? super F> comparator, F... elements) Returns a new sorted collection with the specified elements.static <F> SortedCollection<F>of(Comparator<? super F> comparator, Collection<? extends F> collection) Returns a new sorted collection cloned from the provided collection.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.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.static <F> SortedCollection<F>of(SortedCollection<F> collection) Returns a new sorted collection cloned from the provided sorted collection.static <F> SortedCollection<F>of(SortedCollection<F> collection, Range<F> range) Returns a new sorted collection cloned from the provided sorted collection.Methods inherited from interface net.filipvanlaenen.kolektoj.Collection
contains, containsAll, containsSame, get, getElementCardinality, isEmpty, iterator, size, spliterator, stream, toArray, toArrayMethods inherited from interface net.filipvanlaenen.kolektoj.OrderedCollection
firstIndexOf, getAt, getFirst, getLast, indexOf, lastIndexOf
-
Method Details
-
empty
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
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
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
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
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
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
Returns the greatest element in the collection.- Returns:
- The greatest element in the collection.
- Throws:
IndexOutOfBoundsException- Thrown if the collection is empty.
-
getLeast
Returns the least element in the collection.- Returns:
- The least element in the collection.
- Throws:
IndexOutOfBoundsException- Thrown if the collection is empty.
-
getLessThan
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
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.
-