RangeKt

Added in 1.1.0

public final class RangeKt


Summary

Public methods

static final @NonNull Range<@NonNull T>
<T extends Comparable<@NonNull T>> and(
    @NonNull Range<@NonNull T> receiver,
    @NonNull Range<@NonNull T> other
)

Return the intersection of this range and other.

static final @NonNull Range<@NonNull T>
<T extends Comparable<@NonNull T>> plus(
    @NonNull Range<@NonNull T> receiver,
    @NonNull Range<@NonNull T> other
)

Return the smallest range that includes this and other.

static final @NonNull Range<@NonNull T>
<T extends Comparable<@NonNull T>> plus(
    @NonNull Range<@NonNull T> receiver,
    @NonNull T value
)

Return the smallest range that includes this and value.

static final @NonNull Range<@NonNull T>
<T extends Comparable<@NonNull T>> rangeTo(@NonNull T receiver, @NonNull T that)

Creates a range from this Comparable value to that.

static final @NonNull ClosedRange<@NonNull T>
<T extends Comparable<@NonNull T>> toClosedRange(@NonNull Range<@NonNull T> receiver)

Returns this Range as a ClosedRange.

static final @NonNull Range<@NonNull T>
<T extends Comparable<@NonNull T>> toRange(@NonNull ClosedRange<@NonNull T> receiver)

Returns this ClosedRange as a Range.

Public methods

public static final @NonNull Range<@NonNull T> <T extends Comparable<@NonNull T>> and(
    @NonNull Range<@NonNull T> receiver,
    @NonNull Range<@NonNull T> other
)

Return the intersection of this range and other.

Throws
kotlin.IllegalArgumentException

if this is disjoint from other.

public static final @NonNull Range<@NonNull T> <T extends Comparable<@NonNull T>> plus(
    @NonNull Range<@NonNull T> receiver,
    @NonNull Range<@NonNull T> other
)

Return the smallest range that includes this and other.

public static final @NonNull Range<@NonNull T> <T extends Comparable<@NonNull T>> plus(
    @NonNull Range<@NonNull T> receiver,
    @NonNull T value
)

Return the smallest range that includes this and value.

public static final @NonNull Range<@NonNull T> <T extends Comparable<@NonNull T>> rangeTo(@NonNull T receiver, @NonNull T that)

Creates a range from this Comparable value to that.

Throws
kotlin.IllegalArgumentException

if this value is comparatively smaller than that.

toClosedRange

public static final @NonNull ClosedRange<@NonNull T> <T extends Comparable<@NonNull T>> toClosedRange(@NonNull Range<@NonNull T> receiver)

Returns this Range as a ClosedRange.

public static final @NonNull Range<@NonNull T> <T extends Comparable<@NonNull T>> toRange(@NonNull ClosedRange<@NonNull T> receiver)

Returns this ClosedRange as a Range.