Package-level declarations

Properties

Link copied to clipboard

Tries to parse this as an UUID

Link copied to clipboard

Returns true if all chars in this are ASCII symbols

Link copied to clipboard
@get:JvmName(name = "getIsValid")
val String?.isValid: Boolean
Link copied to clipboard
Link copied to clipboard
@get:JvmName(name = "midpointByte")
val ClosedRange<Byte>.midpoint: Int
@get:JvmName(name = "midpointShort")
val ClosedRange<Short>.midpoint: Int

A middle point of the range. The value is rounded down.

Link copied to clipboard

Returns the next value of this enum (ordered the same way as declared in code, i.e. by ordinal).

Link copied to clipboard

Returns the next value of this enum (ordered the same way as declared in code, i.e. by ordinal).

Link copied to clipboard

Returns the previous value of this enum (ordered the same way as declared in code, i.e. by ordinal).

Link copied to clipboard

Returns the previous value of this enum (ordered the same way as declared in code, i.e. by ordinal).

Link copied to clipboard

Add quotes to this string, if not present.

@get:JvmName(name = "quotedOrNull")
val String?.quoted: String?

Add quotes to this string, if not present. Will do nothing to nulls.

Link copied to clipboard

Returns the sign of this.

Link copied to clipboard

Returns the sign of the number, as a char

Link copied to clipboard
@get:JvmName(name = "sizeByte")
val ClosedRange<Byte>.size: Int
@get:JvmName(name = "sizeShort")
val ClosedRange<Short>.size: Int

Returns the size of this range, from end inclusive to start

Functions

Link copied to clipboard
inline fun <T, K, V> Iterable<T>.associateFirst(key: (T) -> K, value: (T) -> V): Map<K, V>

Returns a Map containing key-value pairs provided by key and value functions applied to elements of the given collection.

inline fun <T, K, V> Sequence<T>.associateFirst(key: (T) -> K, value: (T) -> V): Map<K, V>

Returns a Map containing key-value pairs provided by key and value functions applied to elements of the given sequence.

Link copied to clipboard
@JvmName(name = "avgByte")
fun avg(vararg values: Byte): Int
fun avg(vararg values: Double): Double
fun avg(vararg values: Float): Double
fun avg(vararg values: Int): Int
fun avg(vararg values: Long): Long
Link copied to clipboard
fun <T, R> Iterable<T>.cartesianProduct(other: Iterable<R>): List<Pair<T, R>>

Returns a list of pairs, where each value corresponds to all possible pairings with values from other. this: A, B, C other: 1, 2 this.cartesianProduct(other) = A to 1, A to 2, B to 1, B to 2, C to 1, C to 2

Link copied to clipboard

Will first put this's elements into chunks of size chunkSize, then calculate an average of each of the chunks.

Link copied to clipboard

Produces a range that is fully contained within other range.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
infix operator fun <T : Comparable<T>> ClosedRange<T>.contains(other: ClosedRange<T>): Boolean

Returns true if this range is fully contained within the other range

Link copied to clipboard
fun <T> T.copies(count: Int): List<T>

Fills the list with shallow copies of the receiver

Link copied to clipboard

Produces a range where min value is the minimum between other.start and ClosedRange.start and max value is maximum between other.endInclusive and ClosedRange.endInclusive

Link copied to clipboard
Link copied to clipboard
fun <T> fastLazy(initializer: () -> T): Lazy<T>

Uses LazyThreadSafetyMode.NONE to provide values quicker.

Link copied to clipboard
fun Iterable<String>.filterBySubstring(substring: String?, ignoreCase: Boolean = false): List<String>

Filter this by searching for elements that contain substring, or if string is not String.isValid, the list itself

Link copied to clipboard
fun <K, V> Map<K, V?>.filterNotNullValues(): Map<K, V & Any>

Filters the values in this map, leaving only non-null entries

Link copied to clipboard
fun Float.format(digits: Int, locale: Locale? = null): String

Formats this Float to string using specified number of digits and a given locale

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

Like indexOfFirst but returns null instead of -1. If the not found.

Link copied to clipboard
inline fun String?.isValid(): Boolean
Link copied to clipboard
fun <T, R> List<T>.mapNotNull(transform: (prev: R?, value: T) -> R?): List<R>

The same as a regular mapNotNull, but transform block contains the previous value of the list.

Link copied to clipboard
operator fun ClosedRange<Int>.minus(value: Int): IntRange
operator fun ClosedRange<Long>.minus(value: Long): LongRange

Subtract value from both start and end of the range

Link copied to clipboard
operator fun ClosedRange<Int>.plus(value: Int): IntRange
operator fun ClosedRange<Long>.plus(value: Long): LongRange

Add value to both start and end of the range

Link copied to clipboard
fun <T> Iterable<T>.randomElements(count: Int): List<T>

Returns count number elements from this

Link copied to clipboard

Returns a random index of this collection

Link copied to clipboard
inline fun <T, R> Iterable<T>.reorderBy(order: List<R>, crossinline selector: (T) -> R): List<T>
Link copied to clipboard
inline fun <T> Iterable<T>.replace(item: T, replacement: T.() -> T): List<T>

Creates a copy of this with item replaced with whatever is returned by replacement.

Link copied to clipboard
inline fun <T> Iterable<T>.replaceIf(with: T, predicate: (T) -> Boolean): List<T>
inline fun <T> Iterable<T>.replaceIf(apply: T.() -> T, predicate: (T) -> Boolean): List<T>
Link copied to clipboard

Replaces all values of this with values from src

Link copied to clipboard
fun <T> T?.requireNotNull(): T & Any
inline fun <T> T?.requireNotNull(lazyMessage: () -> Unit): T & Any

Calls requireNotNull on this value and returns it

Link copied to clipboard
@JvmName(name = "rethrowErrorsNotNull")
fun Throwable.rethrowErrors(): Exception

If this is an Error, throws it, otherwise returns this as an Exception

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
infix fun String.spans(range: IntRange): Boolean

Check if this String has length in range

Link copied to clipboard
inline fun <T> Collection<T>.sumOf(selector: (T) -> Float): Float

A sumOf variation that returns a float instead of Double

Link copied to clipboard
fun <T> MutableList<T>.swap(index1: Int, index2: Int): MutableList<T>

Swaps values index1 with index2 in place. Throws IndexOutOfBoundsException when one or both indices are not present in the collection

Link copied to clipboard
fun <T> List<T>.swapped(index1: Int, index2: Int): List<T>

Returns a shallow copy of this list with the items at index1 and index2 swapped. Throws IndexOutOfBoundsException when one or both indices are not present in the collection

Link copied to clipboard
fun <T : Any> List<T>.swappedOrDefault(index1: Int, index2: Int): List<T>

Returns a shallow copy of this list with the items at index1 and index2 swapped. Returns the original collection if either index1 or index2 are not resent

Link copied to clipboard
fun <T> Iterator<T>.take(count: Int): List<T>

Consume this iterator by taking the first count elements

Link copied to clipboard
Link copied to clipboard

Takes this string only if it isValid

Link copied to clipboard

Encode this byte array to base 64

Encode this string to Base64

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Convert this range to an IntRange

Link copied to clipboard

Convert this range to a LongRange

Link copied to clipboard

uses sign and prepends it to the value of this

Link copied to clipboard
inline fun <T> Iterable<T>.tryReplace(item: T, replacement: T.() -> T): List<T>

Tries to replace item with replacement and does nothing if item is not found in this

Link copied to clipboard
fun <T : Any> MutableList<T>.trySwap(index1: Int, index2: Int): MutableList<T>

Swaps values index1 with index2 in place. Returns the original collection if either index1 or index2 are not resent