SortedKeyValueSequence

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

Example:

val sequence = sequenceOf(1 to "a", 2 to "b", 3 to "c").assertSorted()

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

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

Link copied to clipboard

Filters key-value pairs using the provided filter function.

Link copied to clipboard

Filters key-value pairs based on their key using the provided filter function.

Link copied to clipboard

Filters key-value pairs based on their value using the provided filter function.

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 keys, 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 key-value pairs from this sequence with those from another sequence while maintaining sort order.

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

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

Returns a new sequence with transformed values while preserving keys and sort order.

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 this sequence with another sorted sequence based on matching keys.