IterableComparableExtension<T extends Comparable<T>> extension

Extensions that apply to iterables of Comparable elements.

These operations can assume that the elements have a natural ordering, and can therefore omit, or make it optional, for the user to provide a Comparator.

on

Properties

max → T
A maximal element of the iterable.
no setter
maxOrNull → T?
A maximal element of the iterable, or null if the iterable is empty.
no setter
min → T
A minimal element of the iterable.
no setter
minOrNull → T?
A minimal element of the iterable, or null it the iterable is empty.
no setter

Methods

isSorted([Comparator<T>? compare]) bool
Whether the elements are sorted by the compare ordering.
sorted([Comparator<T>? compare]) List<T>
Creates a sorted list of the elements of the iterable.