LongProgression

open class LongProgression(val first: Long, endInclusive: Long, val step: Long) : Iterable<Long> (source)

An ordered progression of Long values with a nonzero, signed step.

Positive steps move upwards; negative steps move downwards. The inclusive last is adjusted to align with first and step, so it may differ from endInclusive. A progression is empty when its bounds run against the step direction.

Parameters

first

the starting value.

endInclusive

the requested inclusive bound in the direction of traversal.

step

the signed difference between successive elements.

Throws

if step is zero or Long.MIN_VALUE.

Inheritors

Constructors

Link copied to clipboard
constructor(first: Long, endInclusive: Long, step: Long)

creates a progression with an aligned final element.

Properties

Link copied to clipboard
val first: Long

The starting value; an empty progression does not yield it.

Link copied to clipboard
val last: Long

The inclusive final element of a nonempty progression, aligned with first and step.

Link copied to clipboard
val step: Long

The signed difference between successive elements; positive for ascending traversal.

Functions

Link copied to clipboard
inline fun <T> Iterable<T>.all(predicate: (T) -> Boolean): Boolean

Returns true when every element matches predicate.

Link copied to clipboard
inline fun <T> Iterable<T>.any(predicate: (T) -> Boolean): Boolean

Returns true when at least one element matches predicate.

Link copied to clipboard

Borrows this iterable as a lazy sequence without traversing or copying it. Each traversal requests a new source iterator; later mutations and invalidation follow the iterable's own contract. Wrappers and iterators use ordinary managed heap quotas.

Link copied to clipboard
operator fun <T> Iterable<T>.contains(element: T): Boolean

Checks whether this iterable has an element equal to element.

Link copied to clipboard
inline fun <T> Iterable<T>.filter(predicate: (T) -> Boolean): List<T>

Returns a list containing elements matching predicate, in their original iteration order.

Link copied to clipboard

Returns a list of non-null elements in their original iteration order.

Link copied to clipboard
inline fun <T, C : MutableCollection<in T>> Iterable<T>.filterTo(destination: C, predicate: (T) -> Boolean): C

Appends matching elements to destination in iteration order.

Link copied to clipboard
inline fun <T> Iterable<T>.find(predicate: (T) -> Boolean): T?

Returns the first matching element, or null when no element matches predicate.

Link copied to clipboard
fun <T> Iterable<T>.first(): T

Returns the first element, throwing NoSuchElementException when empty.

inline fun <T> Iterable<T>.first(predicate: (T) -> Boolean): T

Returns the first matching element, throwing NoSuchElementException when no element matches.

Link copied to clipboard
fun <T> Iterable<T>.firstOrNull(): T?

Returns the first element, or null when this iterable is empty.

inline fun <T> Iterable<T>.firstOrNull(predicate: (T) -> Boolean): T?

Returns the first matching element, or null when no element matches predicate.

Link copied to clipboard
inline fun <T, R> Iterable<T>.fold(initial: R, operation: (R, T) -> R): R

Accumulates elements in iteration order.

Link copied to clipboard
inline fun <T> Iterable<T>.forEach(action: (T) -> Unit)

Calls action for each element in iteration order.

Link copied to clipboard
inline fun <T> Iterable<T>.forEachIndexed(action: (Int, T) -> Unit)

Calls action for each element and its zero-based index in iteration order.

Link copied to clipboard
fun <T> Iterable<T>.indexOf(element: T): Int

Returns the index of the first equal element, or -1 when no element matches.

Link copied to clipboard
open fun isEmpty(): Boolean

Returns whether this progression contains no elements.

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

Creates an independent iterator over this progression in step order.

Link copied to clipboard
fun <T> Iterable<T>.lastIndexOf(element: T): Int

Returns the index of the last equal element, or -1 when no element matches.

Link copied to clipboard
fun <T> Iterable<T>.lastOrNull(): T?

Returns the last element, or null when this iterable is empty.

inline fun <T> Iterable<T>.lastOrNull(predicate: (T) -> Boolean): T?

Returns the last matching element after traversing this iterable in iteration order.

Link copied to clipboard
inline fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R>

Returns a list containing transform applied once to each element in iteration order.

Link copied to clipboard
inline fun <T, R : Any> Iterable<T>.mapNotNull(transform: (T) -> R?): List<R>

Applies transform once per element in iteration order and retains only non-null results.

Link copied to clipboard
inline fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapNotNullTo(destination: C, transform: (T) -> R?): C

Appends non-null transformed elements to destination in iteration order.

Link copied to clipboard
inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapTo(destination: C, transform: (T) -> R): C

Appends transformed elements to destination in iteration order.

Link copied to clipboard
inline fun <T> Iterable<T>.none(predicate: (T) -> Boolean): Boolean

Returns true when no element matches predicate.

Link copied to clipboard

Creates a progression with the same direction and a new positive step magnitude.