Add flatMap sample KT-20357
This commit is contained in:
committed by
Ilya Gorbunov
parent
29b25e3901
commit
664d69b752
@@ -8407,6 +8407,8 @@ public fun CharArray.toSet(): Set<Char> {
|
||||
|
||||
/**
|
||||
* Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.flatMap
|
||||
*/
|
||||
public inline fun <T, R> Array<out T>.flatMap(transform: (T) -> Iterable<R>): List<R> {
|
||||
return flatMapTo(ArrayList<R>(), transform)
|
||||
@@ -8414,6 +8416,8 @@ public inline fun <T, R> Array<out T>.flatMap(transform: (T) -> Iterable<R>): Li
|
||||
|
||||
/**
|
||||
* Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.flatMap
|
||||
*/
|
||||
public inline fun <R> ByteArray.flatMap(transform: (Byte) -> Iterable<R>): List<R> {
|
||||
return flatMapTo(ArrayList<R>(), transform)
|
||||
@@ -8421,6 +8425,8 @@ public inline fun <R> ByteArray.flatMap(transform: (Byte) -> Iterable<R>): List<
|
||||
|
||||
/**
|
||||
* Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.flatMap
|
||||
*/
|
||||
public inline fun <R> ShortArray.flatMap(transform: (Short) -> Iterable<R>): List<R> {
|
||||
return flatMapTo(ArrayList<R>(), transform)
|
||||
@@ -8428,6 +8434,8 @@ public inline fun <R> ShortArray.flatMap(transform: (Short) -> Iterable<R>): Lis
|
||||
|
||||
/**
|
||||
* Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.flatMap
|
||||
*/
|
||||
public inline fun <R> IntArray.flatMap(transform: (Int) -> Iterable<R>): List<R> {
|
||||
return flatMapTo(ArrayList<R>(), transform)
|
||||
@@ -8435,6 +8443,8 @@ public inline fun <R> IntArray.flatMap(transform: (Int) -> Iterable<R>): List<R>
|
||||
|
||||
/**
|
||||
* Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.flatMap
|
||||
*/
|
||||
public inline fun <R> LongArray.flatMap(transform: (Long) -> Iterable<R>): List<R> {
|
||||
return flatMapTo(ArrayList<R>(), transform)
|
||||
@@ -8442,6 +8452,8 @@ public inline fun <R> LongArray.flatMap(transform: (Long) -> Iterable<R>): List<
|
||||
|
||||
/**
|
||||
* Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.flatMap
|
||||
*/
|
||||
public inline fun <R> FloatArray.flatMap(transform: (Float) -> Iterable<R>): List<R> {
|
||||
return flatMapTo(ArrayList<R>(), transform)
|
||||
@@ -8449,6 +8461,8 @@ public inline fun <R> FloatArray.flatMap(transform: (Float) -> Iterable<R>): Lis
|
||||
|
||||
/**
|
||||
* Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.flatMap
|
||||
*/
|
||||
public inline fun <R> DoubleArray.flatMap(transform: (Double) -> Iterable<R>): List<R> {
|
||||
return flatMapTo(ArrayList<R>(), transform)
|
||||
@@ -8456,6 +8470,8 @@ public inline fun <R> DoubleArray.flatMap(transform: (Double) -> Iterable<R>): L
|
||||
|
||||
/**
|
||||
* Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.flatMap
|
||||
*/
|
||||
public inline fun <R> BooleanArray.flatMap(transform: (Boolean) -> Iterable<R>): List<R> {
|
||||
return flatMapTo(ArrayList<R>(), transform)
|
||||
@@ -8463,6 +8479,8 @@ public inline fun <R> BooleanArray.flatMap(transform: (Boolean) -> Iterable<R>):
|
||||
|
||||
/**
|
||||
* Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.flatMap
|
||||
*/
|
||||
public inline fun <R> CharArray.flatMap(transform: (Char) -> Iterable<R>): List<R> {
|
||||
return flatMapTo(ArrayList<R>(), transform)
|
||||
|
||||
@@ -1237,6 +1237,8 @@ public fun <T> Iterable<T>.toSet(): Set<T> {
|
||||
|
||||
/**
|
||||
* Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original collection.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.flatMap
|
||||
*/
|
||||
public inline fun <T, R> Iterable<T>.flatMap(transform: (T) -> Iterable<R>): List<R> {
|
||||
return flatMapTo(ArrayList<R>(), transform)
|
||||
|
||||
@@ -39,6 +39,8 @@ public fun <K, V> Map<out K, V>.toList(): List<Pair<K, V>> {
|
||||
|
||||
/**
|
||||
* Returns a single list of all elements yielded from results of [transform] function being invoked on each entry of original map.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.flatMap
|
||||
*/
|
||||
public inline fun <K, V, R> Map<out K, V>.flatMap(transform: (Map.Entry<K, V>) -> Iterable<R>): List<R> {
|
||||
return flatMapTo(ArrayList<R>(), transform)
|
||||
|
||||
@@ -761,6 +761,8 @@ public fun <T> Sequence<T>.toSet(): Set<T> {
|
||||
* Returns a single sequence of all elements from results of [transform] function being invoked on each element of original sequence.
|
||||
*
|
||||
* The operation is _intermediate_ and _stateless_.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.flatMap
|
||||
*/
|
||||
public fun <T, R> Sequence<T>.flatMap(transform: (T) -> Sequence<R>): Sequence<R> {
|
||||
return FlatteningSequence(this, transform, { it.iterator() })
|
||||
|
||||
@@ -749,6 +749,8 @@ public fun CharSequence.toSet(): Set<Char> {
|
||||
|
||||
/**
|
||||
* Returns a single list of all elements yielded from results of [transform] function being invoked on each character of original char sequence.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.flatMap
|
||||
*/
|
||||
public inline fun <R> CharSequence.flatMap(transform: (Char) -> Iterable<R>): List<R> {
|
||||
return flatMapTo(ArrayList<R>(), transform)
|
||||
|
||||
@@ -3748,6 +3748,8 @@ public inline fun ShortArray.toUShortArray(): UShortArray {
|
||||
|
||||
/**
|
||||
* Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.flatMap
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
@ExperimentalUnsignedTypes
|
||||
@@ -3758,6 +3760,8 @@ public inline fun <R> UIntArray.flatMap(transform: (UInt) -> Iterable<R>): List<
|
||||
|
||||
/**
|
||||
* Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.flatMap
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
@ExperimentalUnsignedTypes
|
||||
@@ -3768,6 +3772,8 @@ public inline fun <R> ULongArray.flatMap(transform: (ULong) -> Iterable<R>): Lis
|
||||
|
||||
/**
|
||||
* Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.flatMap
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
@ExperimentalUnsignedTypes
|
||||
@@ -3778,6 +3784,8 @@ public inline fun <R> UByteArray.flatMap(transform: (UByte) -> Iterable<R>): Lis
|
||||
|
||||
/**
|
||||
* Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.flatMap
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
@ExperimentalUnsignedTypes
|
||||
|
||||
Reference in New Issue
Block a user