All Downloads are FREE. Search and download functionalities are using the official Maven repository.

generated._Mapping.kt Maven / Gradle / Ivy

There is a newer version: 1.0.7
Show newest version
package kotlin

//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
//

import kotlin.platform.*
import java.util.*

import java.util.Collections // TODO: it's temporary while we have java.util.Collections in js

/**
 * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original collection.
 */
public inline fun  Array.flatMap(transform: (T) -> Iterable): List {
    return flatMapTo(ArrayList(), transform)
}

/**
 * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original collection.
 */
public inline fun  BooleanArray.flatMap(transform: (Boolean) -> Iterable): List {
    return flatMapTo(ArrayList(), transform)
}

/**
 * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original collection.
 */
public inline fun  ByteArray.flatMap(transform: (Byte) -> Iterable): List {
    return flatMapTo(ArrayList(), transform)
}

/**
 * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original collection.
 */
public inline fun  CharArray.flatMap(transform: (Char) -> Iterable): List {
    return flatMapTo(ArrayList(), transform)
}

/**
 * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original collection.
 */
public inline fun  DoubleArray.flatMap(transform: (Double) -> Iterable): List {
    return flatMapTo(ArrayList(), transform)
}

/**
 * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original collection.
 */
public inline fun  FloatArray.flatMap(transform: (Float) -> Iterable): List {
    return flatMapTo(ArrayList(), transform)
}

/**
 * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original collection.
 */
public inline fun  IntArray.flatMap(transform: (Int) -> Iterable): List {
    return flatMapTo(ArrayList(), transform)
}

/**
 * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original collection.
 */
public inline fun  LongArray.flatMap(transform: (Long) -> Iterable): List {
    return flatMapTo(ArrayList(), transform)
}

/**
 * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original collection.
 */
public inline fun  ShortArray.flatMap(transform: (Short) -> Iterable): List {
    return flatMapTo(ArrayList(), transform)
}

/**
 * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original collection.
 */
public inline fun  Iterable.flatMap(transform: (T) -> Iterable): List {
    return flatMapTo(ArrayList(), transform)
}

/**
 * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original collection.
 */
public inline fun  Map.flatMap(transform: (Map.Entry) -> Iterable): List {
    return flatMapTo(ArrayList(), transform)
}

/**
 * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original collection.
 */
public inline fun  String.flatMap(transform: (Char) -> Iterable): List {
    return flatMapTo(ArrayList(), transform)
}

/**
 * Returns a single sequence of all elements from results of [transform] function being invoked on each element of original sequence.
 */
public fun  Sequence.flatMap(transform: (T) -> Sequence): Sequence {
    return FlatteningSequence(this, transform)
}

/**
 * Appends all elements yielded from results of [transform] function being invoked on each element of original collection, to the given [destination].
 */
public inline fun > Array.flatMapTo(destination: C, transform: (T) -> Iterable): C {
    for (element in this) {
        val list = transform(element)
        destination.addAll(list)
    }
    return destination
}

/**
 * Appends all elements yielded from results of [transform] function being invoked on each element of original collection, to the given [destination].
 */
public inline fun > BooleanArray.flatMapTo(destination: C, transform: (Boolean) -> Iterable): C {
    for (element in this) {
        val list = transform(element)
        destination.addAll(list)
    }
    return destination
}

/**
 * Appends all elements yielded from results of [transform] function being invoked on each element of original collection, to the given [destination].
 */
public inline fun > ByteArray.flatMapTo(destination: C, transform: (Byte) -> Iterable): C {
    for (element in this) {
        val list = transform(element)
        destination.addAll(list)
    }
    return destination
}

/**
 * Appends all elements yielded from results of [transform] function being invoked on each element of original collection, to the given [destination].
 */
public inline fun > CharArray.flatMapTo(destination: C, transform: (Char) -> Iterable): C {
    for (element in this) {
        val list = transform(element)
        destination.addAll(list)
    }
    return destination
}

/**
 * Appends all elements yielded from results of [transform] function being invoked on each element of original collection, to the given [destination].
 */
public inline fun > DoubleArray.flatMapTo(destination: C, transform: (Double) -> Iterable): C {
    for (element in this) {
        val list = transform(element)
        destination.addAll(list)
    }
    return destination
}

/**
 * Appends all elements yielded from results of [transform] function being invoked on each element of original collection, to the given [destination].
 */
public inline fun > FloatArray.flatMapTo(destination: C, transform: (Float) -> Iterable): C {
    for (element in this) {
        val list = transform(element)
        destination.addAll(list)
    }
    return destination
}

/**
 * Appends all elements yielded from results of [transform] function being invoked on each element of original collection, to the given [destination].
 */
public inline fun > IntArray.flatMapTo(destination: C, transform: (Int) -> Iterable): C {
    for (element in this) {
        val list = transform(element)
        destination.addAll(list)
    }
    return destination
}

/**
 * Appends all elements yielded from results of [transform] function being invoked on each element of original collection, to the given [destination].
 */
public inline fun > LongArray.flatMapTo(destination: C, transform: (Long) -> Iterable): C {
    for (element in this) {
        val list = transform(element)
        destination.addAll(list)
    }
    return destination
}

/**
 * Appends all elements yielded from results of [transform] function being invoked on each element of original collection, to the given [destination].
 */
public inline fun > ShortArray.flatMapTo(destination: C, transform: (Short) -> Iterable): C {
    for (element in this) {
        val list = transform(element)
        destination.addAll(list)
    }
    return destination
}

/**
 * Appends all elements yielded from results of [transform] function being invoked on each element of original collection, to the given [destination].
 */
public inline fun > Iterable.flatMapTo(destination: C, transform: (T) -> Iterable): C {
    for (element in this) {
        val list = transform(element)
        destination.addAll(list)
    }
    return destination
}

/**
 * Appends all elements yielded from results of [transform] function being invoked on each element of original collection, to the given [destination].
 */
public inline fun > Map.flatMapTo(destination: C, transform: (Map.Entry) -> Iterable): C {
    for (element in this) {
        val list = transform(element)
        destination.addAll(list)
    }
    return destination
}

/**
 * Appends all elements yielded from results of [transform] function being invoked on each element of original collection, to the given [destination].
 */
public inline fun > String.flatMapTo(destination: C, transform: (Char) -> Iterable): C {
    for (element in this) {
        val list = transform(element)
        destination.addAll(list)
    }
    return destination
}

/**
 * Appends all elements yielded from results of [transform] function being invoked on each element of original sequence, to the given [destination].
 */
public inline fun > Sequence.flatMapTo(destination: C, transform: (T) -> Sequence): C {
    for (element in this) {
        val list = transform(element)
        destination.addAll(list)
    }
    return destination
}

/**
 * Returns a map of the elements in original collection grouped by the result of given [toKey] function.
 */
public inline fun  Array.groupBy(toKey: (T) -> K): Map> {
    return groupByTo(LinkedHashMap>(), toKey)
}

/**
 * Returns a map of the elements in original collection grouped by the result of given [toKey] function.
 */
public inline fun  BooleanArray.groupBy(toKey: (Boolean) -> K): Map> {
    return groupByTo(LinkedHashMap>(), toKey)
}

/**
 * Returns a map of the elements in original collection grouped by the result of given [toKey] function.
 */
public inline fun  ByteArray.groupBy(toKey: (Byte) -> K): Map> {
    return groupByTo(LinkedHashMap>(), toKey)
}

/**
 * Returns a map of the elements in original collection grouped by the result of given [toKey] function.
 */
public inline fun  CharArray.groupBy(toKey: (Char) -> K): Map> {
    return groupByTo(LinkedHashMap>(), toKey)
}

/**
 * Returns a map of the elements in original collection grouped by the result of given [toKey] function.
 */
public inline fun  DoubleArray.groupBy(toKey: (Double) -> K): Map> {
    return groupByTo(LinkedHashMap>(), toKey)
}

/**
 * Returns a map of the elements in original collection grouped by the result of given [toKey] function.
 */
public inline fun  FloatArray.groupBy(toKey: (Float) -> K): Map> {
    return groupByTo(LinkedHashMap>(), toKey)
}

/**
 * Returns a map of the elements in original collection grouped by the result of given [toKey] function.
 */
public inline fun  IntArray.groupBy(toKey: (Int) -> K): Map> {
    return groupByTo(LinkedHashMap>(), toKey)
}

/**
 * Returns a map of the elements in original collection grouped by the result of given [toKey] function.
 */
public inline fun  LongArray.groupBy(toKey: (Long) -> K): Map> {
    return groupByTo(LinkedHashMap>(), toKey)
}

/**
 * Returns a map of the elements in original collection grouped by the result of given [toKey] function.
 */
public inline fun  ShortArray.groupBy(toKey: (Short) -> K): Map> {
    return groupByTo(LinkedHashMap>(), toKey)
}

/**
 * Returns a map of the elements in original collection grouped by the result of given [toKey] function.
 */
public inline fun  Iterable.groupBy(toKey: (T) -> K): Map> {
    return groupByTo(LinkedHashMap>(), toKey)
}

/**
 * Returns a map of the elements in original collection grouped by the result of given [toKey] function.
 */
public inline fun  Sequence.groupBy(toKey: (T) -> K): Map> {
    return groupByTo(LinkedHashMap>(), toKey)
}

/**
 * Returns a map of the elements in original collection grouped by the result of given [toKey] function.
 */
public inline fun  String.groupBy(toKey: (Char) -> K): Map> {
    return groupByTo(LinkedHashMap>(), toKey)
}

/**
 * Appends elements from original collection grouped by the result of given [toKey] function to the given [map].
 */
public inline fun  Array.groupByTo(map: MutableMap>, toKey: (T) -> K): Map> {
    for (element in this) {
        val key = toKey(element)
        val list = map.getOrPut(key) { ArrayList() }
        list.add(element)
    }
    return map
}

/**
 * Appends elements from original collection grouped by the result of given [toKey] function to the given [map].
 */
public inline fun  BooleanArray.groupByTo(map: MutableMap>, toKey: (Boolean) -> K): Map> {
    for (element in this) {
        val key = toKey(element)
        val list = map.getOrPut(key) { ArrayList() }
        list.add(element)
    }
    return map
}

/**
 * Appends elements from original collection grouped by the result of given [toKey] function to the given [map].
 */
public inline fun  ByteArray.groupByTo(map: MutableMap>, toKey: (Byte) -> K): Map> {
    for (element in this) {
        val key = toKey(element)
        val list = map.getOrPut(key) { ArrayList() }
        list.add(element)
    }
    return map
}

/**
 * Appends elements from original collection grouped by the result of given [toKey] function to the given [map].
 */
public inline fun  CharArray.groupByTo(map: MutableMap>, toKey: (Char) -> K): Map> {
    for (element in this) {
        val key = toKey(element)
        val list = map.getOrPut(key) { ArrayList() }
        list.add(element)
    }
    return map
}

/**
 * Appends elements from original collection grouped by the result of given [toKey] function to the given [map].
 */
public inline fun  DoubleArray.groupByTo(map: MutableMap>, toKey: (Double) -> K): Map> {
    for (element in this) {
        val key = toKey(element)
        val list = map.getOrPut(key) { ArrayList() }
        list.add(element)
    }
    return map
}

/**
 * Appends elements from original collection grouped by the result of given [toKey] function to the given [map].
 */
public inline fun  FloatArray.groupByTo(map: MutableMap>, toKey: (Float) -> K): Map> {
    for (element in this) {
        val key = toKey(element)
        val list = map.getOrPut(key) { ArrayList() }
        list.add(element)
    }
    return map
}

/**
 * Appends elements from original collection grouped by the result of given [toKey] function to the given [map].
 */
public inline fun  IntArray.groupByTo(map: MutableMap>, toKey: (Int) -> K): Map> {
    for (element in this) {
        val key = toKey(element)
        val list = map.getOrPut(key) { ArrayList() }
        list.add(element)
    }
    return map
}

/**
 * Appends elements from original collection grouped by the result of given [toKey] function to the given [map].
 */
public inline fun  LongArray.groupByTo(map: MutableMap>, toKey: (Long) -> K): Map> {
    for (element in this) {
        val key = toKey(element)
        val list = map.getOrPut(key) { ArrayList() }
        list.add(element)
    }
    return map
}

/**
 * Appends elements from original collection grouped by the result of given [toKey] function to the given [map].
 */
public inline fun  ShortArray.groupByTo(map: MutableMap>, toKey: (Short) -> K): Map> {
    for (element in this) {
        val key = toKey(element)
        val list = map.getOrPut(key) { ArrayList() }
        list.add(element)
    }
    return map
}

/**
 * Appends elements from original collection grouped by the result of given [toKey] function to the given [map].
 */
public inline fun  Iterable.groupByTo(map: MutableMap>, toKey: (T) -> K): Map> {
    for (element in this) {
        val key = toKey(element)
        val list = map.getOrPut(key) { ArrayList() }
        list.add(element)
    }
    return map
}

/**
 * Appends elements from original collection grouped by the result of given [toKey] function to the given [map].
 */
public inline fun  Sequence.groupByTo(map: MutableMap>, toKey: (T) -> K): Map> {
    for (element in this) {
        val key = toKey(element)
        val list = map.getOrPut(key) { ArrayList() }
        list.add(element)
    }
    return map
}

/**
 * Appends elements from original collection grouped by the result of given [toKey] function to the given [map].
 */
public inline fun  String.groupByTo(map: MutableMap>, toKey: (Char) -> K): Map> {
    for (element in this) {
        val key = toKey(element)
        val list = map.getOrPut(key) { ArrayList() }
        list.add(element)
    }
    return map
}

/**
 * Returns a list containing the results of applying the given [transform] function to each element of the original collection.
 */
public inline fun  Array.map(transform: (T) -> R): List {
    return mapTo(ArrayList(size()), transform)
}

/**
 * Returns a list containing the results of applying the given [transform] function to each element of the original collection.
 */
public inline fun  BooleanArray.map(transform: (Boolean) -> R): List {
    return mapTo(ArrayList(size()), transform)
}

/**
 * Returns a list containing the results of applying the given [transform] function to each element of the original collection.
 */
public inline fun  ByteArray.map(transform: (Byte) -> R): List {
    return mapTo(ArrayList(size()), transform)
}

/**
 * Returns a list containing the results of applying the given [transform] function to each element of the original collection.
 */
public inline fun  CharArray.map(transform: (Char) -> R): List {
    return mapTo(ArrayList(size()), transform)
}

/**
 * Returns a list containing the results of applying the given [transform] function to each element of the original collection.
 */
public inline fun  DoubleArray.map(transform: (Double) -> R): List {
    return mapTo(ArrayList(size()), transform)
}

/**
 * Returns a list containing the results of applying the given [transform] function to each element of the original collection.
 */
public inline fun  FloatArray.map(transform: (Float) -> R): List {
    return mapTo(ArrayList(size()), transform)
}

/**
 * Returns a list containing the results of applying the given [transform] function to each element of the original collection.
 */
public inline fun  IntArray.map(transform: (Int) -> R): List {
    return mapTo(ArrayList(size()), transform)
}

/**
 * Returns a list containing the results of applying the given [transform] function to each element of the original collection.
 */
public inline fun  LongArray.map(transform: (Long) -> R): List {
    return mapTo(ArrayList(size()), transform)
}

/**
 * Returns a list containing the results of applying the given [transform] function to each element of the original collection.
 */
public inline fun  ShortArray.map(transform: (Short) -> R): List {
    return mapTo(ArrayList(size()), transform)
}

/**
 * Returns a list containing the results of applying the given [transform] function to each element of the original collection.
 */
public inline fun  Iterable.map(transform: (T) -> R): List {
    return mapTo(ArrayList(collectionSizeOrDefault(10)), transform)
}

/**
 * Returns a list containing the results of applying the given [transform] function to each element of the original collection.
 */
public inline fun  Map.map(transform: (Map.Entry) -> R): List {
    return mapTo(ArrayList(size()), transform)
}

/**
 * Returns a sequence containing the results of applying the given [transform] function to each element of the original sequence.
 */
public fun  Sequence.map(transform: (T) -> R): Sequence {
    return TransformingSequence(this, transform)
}

/**
 * Returns a list containing the results of applying the given [transform] function to each element of the original collection.
 */
public inline fun  String.map(transform: (Char) -> R): List {
    return mapTo(ArrayList(length()), transform)
}

/**
 * Returns a list containing the results of applying the given [transform] function to each element and its index of the original collection.
 */
public inline fun  Array.mapIndexed(transform: (Int, T) -> R): List {
    return mapIndexedTo(ArrayList(size()), transform)
}

/**
 * Returns a list containing the results of applying the given [transform] function to each element and its index of the original collection.
 */
public inline fun  BooleanArray.mapIndexed(transform: (Int, Boolean) -> R): List {
    return mapIndexedTo(ArrayList(size()), transform)
}

/**
 * Returns a list containing the results of applying the given [transform] function to each element and its index of the original collection.
 */
public inline fun  ByteArray.mapIndexed(transform: (Int, Byte) -> R): List {
    return mapIndexedTo(ArrayList(size()), transform)
}

/**
 * Returns a list containing the results of applying the given [transform] function to each element and its index of the original collection.
 */
public inline fun  CharArray.mapIndexed(transform: (Int, Char) -> R): List {
    return mapIndexedTo(ArrayList(size()), transform)
}

/**
 * Returns a list containing the results of applying the given [transform] function to each element and its index of the original collection.
 */
public inline fun  DoubleArray.mapIndexed(transform: (Int, Double) -> R): List {
    return mapIndexedTo(ArrayList(size()), transform)
}

/**
 * Returns a list containing the results of applying the given [transform] function to each element and its index of the original collection.
 */
public inline fun  FloatArray.mapIndexed(transform: (Int, Float) -> R): List {
    return mapIndexedTo(ArrayList(size()), transform)
}

/**
 * Returns a list containing the results of applying the given [transform] function to each element and its index of the original collection.
 */
public inline fun  IntArray.mapIndexed(transform: (Int, Int) -> R): List {
    return mapIndexedTo(ArrayList(size()), transform)
}

/**
 * Returns a list containing the results of applying the given [transform] function to each element and its index of the original collection.
 */
public inline fun  LongArray.mapIndexed(transform: (Int, Long) -> R): List {
    return mapIndexedTo(ArrayList(size()), transform)
}

/**
 * Returns a list containing the results of applying the given [transform] function to each element and its index of the original collection.
 */
public inline fun  ShortArray.mapIndexed(transform: (Int, Short) -> R): List {
    return mapIndexedTo(ArrayList(size()), transform)
}

/**
 * Returns a list containing the results of applying the given [transform] function to each element and its index of the original collection.
 */
public inline fun  Iterable.mapIndexed(transform: (Int, T) -> R): List {
    return mapIndexedTo(ArrayList(collectionSizeOrDefault(10)), transform)
}

/**
 * Returns a sequence containing the results of applying the given [transform] function to each element and its index of the original sequence.
 */
public fun  Sequence.mapIndexed(transform: (Int, T) -> R): Sequence {
    return TransformingIndexedSequence(this, transform)
}

/**
 * Returns a list containing the results of applying the given [transform] function to each element and its index of the original collection.
 */
public inline fun  String.mapIndexed(transform: (Int, Char) -> R): List {
    return mapIndexedTo(ArrayList(length()), transform)
}

/**
 * Appends transformed elements and their indices of the original collection using the given [transform] function
 * to the given [destination].
 */
public inline fun > Array.mapIndexedTo(destination: C, transform: (Int, T) -> R): C {
    var index = 0
    for (item in this)
        destination.add(transform(index++, item))
    return destination
}

/**
 * Appends transformed elements and their indices of the original collection using the given [transform] function
 * to the given [destination].
 */
public inline fun > BooleanArray.mapIndexedTo(destination: C, transform: (Int, Boolean) -> R): C {
    var index = 0
    for (item in this)
        destination.add(transform(index++, item))
    return destination
}

/**
 * Appends transformed elements and their indices of the original collection using the given [transform] function
 * to the given [destination].
 */
public inline fun > ByteArray.mapIndexedTo(destination: C, transform: (Int, Byte) -> R): C {
    var index = 0
    for (item in this)
        destination.add(transform(index++, item))
    return destination
}

/**
 * Appends transformed elements and their indices of the original collection using the given [transform] function
 * to the given [destination].
 */
public inline fun > CharArray.mapIndexedTo(destination: C, transform: (Int, Char) -> R): C {
    var index = 0
    for (item in this)
        destination.add(transform(index++, item))
    return destination
}

/**
 * Appends transformed elements and their indices of the original collection using the given [transform] function
 * to the given [destination].
 */
public inline fun > DoubleArray.mapIndexedTo(destination: C, transform: (Int, Double) -> R): C {
    var index = 0
    for (item in this)
        destination.add(transform(index++, item))
    return destination
}

/**
 * Appends transformed elements and their indices of the original collection using the given [transform] function
 * to the given [destination].
 */
public inline fun > FloatArray.mapIndexedTo(destination: C, transform: (Int, Float) -> R): C {
    var index = 0
    for (item in this)
        destination.add(transform(index++, item))
    return destination
}

/**
 * Appends transformed elements and their indices of the original collection using the given [transform] function
 * to the given [destination].
 */
public inline fun > IntArray.mapIndexedTo(destination: C, transform: (Int, Int) -> R): C {
    var index = 0
    for (item in this)
        destination.add(transform(index++, item))
    return destination
}

/**
 * Appends transformed elements and their indices of the original collection using the given [transform] function
 * to the given [destination].
 */
public inline fun > LongArray.mapIndexedTo(destination: C, transform: (Int, Long) -> R): C {
    var index = 0
    for (item in this)
        destination.add(transform(index++, item))
    return destination
}

/**
 * Appends transformed elements and their indices of the original collection using the given [transform] function
 * to the given [destination].
 */
public inline fun > ShortArray.mapIndexedTo(destination: C, transform: (Int, Short) -> R): C {
    var index = 0
    for (item in this)
        destination.add(transform(index++, item))
    return destination
}

/**
 * Appends transformed elements and their indices of the original collection using the given [transform] function
 * to the given [destination].
 */
public inline fun > Iterable.mapIndexedTo(destination: C, transform: (Int, T) -> R): C {
    var index = 0
    for (item in this)
        destination.add(transform(index++, item))
    return destination
}

/**
 * Appends transformed elements and their indices of the original collection using the given [transform] function
 * to the given [destination].
 */
public inline fun > Map.mapIndexedTo(destination: C, transform: (Int, Map.Entry) -> R): C {
    var index = 0
    for (item in this)
        destination.add(transform(index++, item))
    return destination
}

/**
 * Appends transformed elements and their indices of the original collection using the given [transform] function
 * to the given [destination].
 */
public inline fun > Sequence.mapIndexedTo(destination: C, transform: (Int, T) -> R): C {
    var index = 0
    for (item in this)
        destination.add(transform(index++, item))
    return destination
}

/**
 * Appends transformed elements and their indices of the original collection using the given [transform] function
 * to the given [destination].
 */
public inline fun > String.mapIndexedTo(destination: C, transform: (Int, Char) -> R): C {
    var index = 0
    for (item in this)
        destination.add(transform(index++, item))
    return destination
}

/**
 * Returns a list containing the results of applying the given [transform] function to each non-null element of the original collection.
 */
public inline fun  Array.mapNotNull(transform: (T) -> R): List {
    return mapNotNullTo(ArrayList(), transform)
}

/**
 * Returns a list containing the results of applying the given [transform] function to each non-null element of the original collection.
 */
public inline fun  Iterable.mapNotNull(transform: (T) -> R): List {
    return mapNotNullTo(ArrayList(), transform)
}

/**
 * Returns a sequence containing the results of applying the given [transform] function to each non-null element of the original sequence.
 */
public fun  Sequence.mapNotNull(transform: (T) -> R): Sequence {
    return TransformingSequence(FilteringSequence(this, false, { it == null }) as Sequence, transform)
}

/**
 * Appends transformed non-null elements of original collection using the given [transform] function
 * to the given [destination].
 */
public inline fun > Array.mapNotNullTo(destination: C, transform: (T) -> R): C {
    for (element in this) {
        if (element != null) {
            destination.add(transform(element))
        }
    }
    return destination
}

/**
 * Appends transformed non-null elements of original collection using the given [transform] function
 * to the given [destination].
 */
public inline fun > Iterable.mapNotNullTo(destination: C, transform: (T) -> R): C {
    for (element in this) {
        if (element != null) {
            destination.add(transform(element))
        }
    }
    return destination
}

/**
 * Appends transformed non-null elements of original collection using the given [transform] function
 * to the given [destination].
 */
public inline fun > Sequence.mapNotNullTo(destination: C, transform: (T) -> R): C {
    for (element in this) {
        if (element != null) {
            destination.add(transform(element))
        }
    }
    return destination
}

/**
 * Appends transformed elements of the original collection using the given [transform] function
 * to the given [destination].
 */
public inline fun > Array.mapTo(destination: C, transform: (T) -> R): C {
    for (item in this)
        destination.add(transform(item))
    return destination
}

/**
 * Appends transformed elements of the original collection using the given [transform] function
 * to the given [destination].
 */
public inline fun > BooleanArray.mapTo(destination: C, transform: (Boolean) -> R): C {
    for (item in this)
        destination.add(transform(item))
    return destination
}

/**
 * Appends transformed elements of the original collection using the given [transform] function
 * to the given [destination].
 */
public inline fun > ByteArray.mapTo(destination: C, transform: (Byte) -> R): C {
    for (item in this)
        destination.add(transform(item))
    return destination
}

/**
 * Appends transformed elements of the original collection using the given [transform] function
 * to the given [destination].
 */
public inline fun > CharArray.mapTo(destination: C, transform: (Char) -> R): C {
    for (item in this)
        destination.add(transform(item))
    return destination
}

/**
 * Appends transformed elements of the original collection using the given [transform] function
 * to the given [destination].
 */
public inline fun > DoubleArray.mapTo(destination: C, transform: (Double) -> R): C {
    for (item in this)
        destination.add(transform(item))
    return destination
}

/**
 * Appends transformed elements of the original collection using the given [transform] function
 * to the given [destination].
 */
public inline fun > FloatArray.mapTo(destination: C, transform: (Float) -> R): C {
    for (item in this)
        destination.add(transform(item))
    return destination
}

/**
 * Appends transformed elements of the original collection using the given [transform] function
 * to the given [destination].
 */
public inline fun > IntArray.mapTo(destination: C, transform: (Int) -> R): C {
    for (item in this)
        destination.add(transform(item))
    return destination
}

/**
 * Appends transformed elements of the original collection using the given [transform] function
 * to the given [destination].
 */
public inline fun > LongArray.mapTo(destination: C, transform: (Long) -> R): C {
    for (item in this)
        destination.add(transform(item))
    return destination
}

/**
 * Appends transformed elements of the original collection using the given [transform] function
 * to the given [destination].
 */
public inline fun > ShortArray.mapTo(destination: C, transform: (Short) -> R): C {
    for (item in this)
        destination.add(transform(item))
    return destination
}

/**
 * Appends transformed elements of the original collection using the given [transform] function
 * to the given [destination].
 */
public inline fun > Iterable.mapTo(destination: C, transform: (T) -> R): C {
    for (item in this)
        destination.add(transform(item))
    return destination
}

/**
 * Appends transformed elements of the original collection using the given [transform] function
 * to the given [destination].
 */
public inline fun > Map.mapTo(destination: C, transform: (Map.Entry) -> R): C {
    for (item in this)
        destination.add(transform(item))
    return destination
}

/**
 * Appends transformed elements of the original collection using the given [transform] function
 * to the given [destination].
 */
public inline fun > Sequence.mapTo(destination: C, transform: (T) -> R): C {
    for (item in this)
        destination.add(transform(item))
    return destination
}

/**
 * Appends transformed elements of the original collection using the given [transform] function
 * to the given [destination].
 */
public inline fun > String.mapTo(destination: C, transform: (Char) -> R): C {
    for (item in this)
        destination.add(transform(item))
    return destination
}

/**
 * Returns a lazy [Iterable] of [IndexedValue] for each element of the original collection.
 */
public fun  Array.withIndex(): Iterable> {
    return IndexingIterable { iterator() }
}

/**
 * Returns a lazy [Iterable] of [IndexedValue] for each element of the original collection.
 */
public fun BooleanArray.withIndex(): Iterable> {
    return IndexingIterable { iterator() }
}

/**
 * Returns a lazy [Iterable] of [IndexedValue] for each element of the original collection.
 */
public fun ByteArray.withIndex(): Iterable> {
    return IndexingIterable { iterator() }
}

/**
 * Returns a lazy [Iterable] of [IndexedValue] for each element of the original collection.
 */
public fun CharArray.withIndex(): Iterable> {
    return IndexingIterable { iterator() }
}

/**
 * Returns a lazy [Iterable] of [IndexedValue] for each element of the original collection.
 */
public fun DoubleArray.withIndex(): Iterable> {
    return IndexingIterable { iterator() }
}

/**
 * Returns a lazy [Iterable] of [IndexedValue] for each element of the original collection.
 */
public fun FloatArray.withIndex(): Iterable> {
    return IndexingIterable { iterator() }
}

/**
 * Returns a lazy [Iterable] of [IndexedValue] for each element of the original collection.
 */
public fun IntArray.withIndex(): Iterable> {
    return IndexingIterable { iterator() }
}

/**
 * Returns a lazy [Iterable] of [IndexedValue] for each element of the original collection.
 */
public fun LongArray.withIndex(): Iterable> {
    return IndexingIterable { iterator() }
}

/**
 * Returns a lazy [Iterable] of [IndexedValue] for each element of the original collection.
 */
public fun ShortArray.withIndex(): Iterable> {
    return IndexingIterable { iterator() }
}

/**
 * Returns a lazy [Iterable] of [IndexedValue] for each element of the original collection.
 */
public fun  Iterable.withIndex(): Iterable> {
    return IndexingIterable { iterator() }
}

/**
 * Returns a sequence of [IndexedValue] for each element of the original sequence.
 */
public fun  Sequence.withIndex(): Sequence> {
    return IndexingSequence(this)
}

/**
 * Returns a lazy [Iterable] of [IndexedValue] for each element of the original collection.
 */
public fun String.withIndex(): Iterable> {
    return IndexingIterable { iterator() }
}

/**
 * Returns a list containing pairs of each element of the original collection and their index.
 */
deprecated("Use withIndex() instead.")
public fun  Array.withIndices(): List> {
    var index = 0
    return mapTo(ArrayList>(), { index++ to it })
}

/**
 * Returns a list containing pairs of each element of the original collection and their index.
 */
deprecated("Use withIndex() instead.")
public fun BooleanArray.withIndices(): List> {
    var index = 0
    return mapTo(ArrayList>(), { index++ to it })
}

/**
 * Returns a list containing pairs of each element of the original collection and their index.
 */
deprecated("Use withIndex() instead.")
public fun ByteArray.withIndices(): List> {
    var index = 0
    return mapTo(ArrayList>(), { index++ to it })
}

/**
 * Returns a list containing pairs of each element of the original collection and their index.
 */
deprecated("Use withIndex() instead.")
public fun CharArray.withIndices(): List> {
    var index = 0
    return mapTo(ArrayList>(), { index++ to it })
}

/**
 * Returns a list containing pairs of each element of the original collection and their index.
 */
deprecated("Use withIndex() instead.")
public fun DoubleArray.withIndices(): List> {
    var index = 0
    return mapTo(ArrayList>(), { index++ to it })
}

/**
 * Returns a list containing pairs of each element of the original collection and their index.
 */
deprecated("Use withIndex() instead.")
public fun FloatArray.withIndices(): List> {
    var index = 0
    return mapTo(ArrayList>(), { index++ to it })
}

/**
 * Returns a list containing pairs of each element of the original collection and their index.
 */
deprecated("Use withIndex() instead.")
public fun IntArray.withIndices(): List> {
    var index = 0
    return mapTo(ArrayList>(), { index++ to it })
}

/**
 * Returns a list containing pairs of each element of the original collection and their index.
 */
deprecated("Use withIndex() instead.")
public fun LongArray.withIndices(): List> {
    var index = 0
    return mapTo(ArrayList>(), { index++ to it })
}

/**
 * Returns a list containing pairs of each element of the original collection and their index.
 */
deprecated("Use withIndex() instead.")
public fun ShortArray.withIndices(): List> {
    var index = 0
    return mapTo(ArrayList>(), { index++ to it })
}

/**
 * Returns a list containing pairs of each element of the original collection and their index.
 */
deprecated("Use withIndex() instead.")
public fun  Iterable.withIndices(): List> {
    var index = 0
    return mapTo(ArrayList>(), { index++ to it })
}

/**
 * Returns a sequence containing pairs of each element of the original collection and their index.
 */
deprecated("Use withIndex() instead.")
public fun  Sequence.withIndices(): Sequence> {
    var index = 0
    return TransformingSequence(this, { index++ to it })
}

/**
 * Returns a list containing pairs of each element of the original collection and their index.
 */
deprecated("Use withIndex() instead.")
public fun String.withIndices(): List> {
    var index = 0
    return mapTo(ArrayList>(), { index++ to it })
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy