SortedSequence

Represents a sequence of elements that are sorted by key. This class provides operations for working with sorted sequences like mapping values, grouping and joining.

Example:

val sequence = sequenceOf("az", "by", "cx").assertSortedBy { it.first() }

Parameters

TKey

The type of keys in the sequence, must be comparable

TValue

The type of values in the sequence

Types

Link copied to clipboard
object Factory

Properties

Link copied to clipboard
open override val sortOrder: SortOrder

The sort order (ascending/descending) of the sequence

Functions

Link copied to clipboard

Creates a SortedKeyValueSequence from this sequence, asserting that elements are sorted by their key.

fun <T : Comparable<T>> Sequence<T>.assertSorted(sortOrder: SortOrder = ASCENDING): SortedSequence<T, T>

Creates a SortedSequence from this sequence, asserting that elements are sorted according to their natural order.

Link copied to clipboard
fun <TKey : Comparable<TKey>, TValue> Sequence<TValue>.assertSortedBy(sortOrder: SortOrder = ASCENDING, keySelector: (TValue) -> TKey): SortedSequence<TKey, TValue>

Creates a SortedSequence from this sequence, asserting that elements are sorted by the given key selector.

Link copied to clipboard

Converts this SortedSequence to a SortedKeyValueSequence.

Link copied to clipboard

Returns a new sequence containing only the first occurrence of each key.

Link copied to clipboard

Filters the sequence to only include elements whose values match the given predicate. This is an alias for filterByValue.

Link copied to clipboard

Filters the sequence to only include elements whose keys match the given predicate.

Link copied to clipboard

Filters the sequence to only include elements whose values match the given predicate.

Link copied to clipboard

Performs a full outer join with another sorted sequence using default pairing of values.

Performs a full outer join with another sorted sequence.

Link copied to clipboard

Performs a full outer zip with another sorted sequence using default pairing of values.

Performs a full outer zip with another sorted sequence.

Link copied to clipboard

Groups values by their sorting key, maintaining sort order.

Link copied to clipboard

Performs an inner join with another sorted sequence using default pairing of values.

Performs an inner join with another sorted sequence.

Link copied to clipboard

Performs an inner zip with another sorted sequence using default pairing of values.

Performs an inner zip with another sorted sequence.

Link copied to clipboard

Interleaves elements from this sequence with those from another sequence while maintaining sort order.

Link copied to clipboard
open operator override fun iterator(): Iterator<TValue>
Link copied to clipboard

Performs a join between two sorted sequences based on matching keys using default pairing of values.

Performs a join between two sorted sequences based on matching keys.

Link copied to clipboard
open override fun keyValueIterator(): Iterator<Pair<TKey, TValue>>

Returns an iterator over the key-value pairs in this sequence while verifying the sort order.

Link copied to clipboard

Performs a left outer join with another sorted sequence using default pairing of values.

Performs a left outer join with another sorted sequence.

Link copied to clipboard

Performs a left outer zip with another sorted sequence using default pairing of values.

Performs a left outer zip with another sorted sequence.

Link copied to clipboard

Performs a right outer join with another sorted sequence using default pairing of values.

Performs a right outer join with another sorted sequence.

Link copied to clipboard

Performs a right outer zip with another sorted sequence using default pairing of values.

Performs a right outer zip with another sorted sequence.

Link copied to clipboard

Zips the sequence with another sorted sequence using default pairing of values.

Zips the sequence with another sorted sequence based on matching keys.