Add map() documentation sample

* docs: add map() sample
* docs: add samples for Map and CharSequence
* docs: add another sample for Maps.map()
This commit is contained in:
Benjamin Orsini
2019-05-20 18:20:09 +02:00
committed by ilya-g
parent 08ea982688
commit 3e39f26379
10 changed files with 69 additions and 1 deletions
@@ -8757,6 +8757,8 @@ public inline fun <T, K> Array<out T>.groupingBy(crossinline keySelector: (T) ->
/**
* Returns a list containing the results of applying the given [transform] function
* to each element in the original array.
*
* @sample samples.collections.Collections.Transformations.map
*/
public inline fun <T, R> Array<out T>.map(transform: (T) -> R): List<R> {
return mapTo(ArrayList<R>(size), transform)
@@ -8765,6 +8767,8 @@ public inline fun <T, R> Array<out T>.map(transform: (T) -> R): List<R> {
/**
* Returns a list containing the results of applying the given [transform] function
* to each element in the original array.
*
* @sample samples.collections.Collections.Transformations.map
*/
public inline fun <R> ByteArray.map(transform: (Byte) -> R): List<R> {
return mapTo(ArrayList<R>(size), transform)
@@ -8773,6 +8777,8 @@ public inline fun <R> ByteArray.map(transform: (Byte) -> R): List<R> {
/**
* Returns a list containing the results of applying the given [transform] function
* to each element in the original array.
*
* @sample samples.collections.Collections.Transformations.map
*/
public inline fun <R> ShortArray.map(transform: (Short) -> R): List<R> {
return mapTo(ArrayList<R>(size), transform)
@@ -8781,6 +8787,8 @@ public inline fun <R> ShortArray.map(transform: (Short) -> R): List<R> {
/**
* Returns a list containing the results of applying the given [transform] function
* to each element in the original array.
*
* @sample samples.collections.Collections.Transformations.map
*/
public inline fun <R> IntArray.map(transform: (Int) -> R): List<R> {
return mapTo(ArrayList<R>(size), transform)
@@ -8789,6 +8797,8 @@ public inline fun <R> IntArray.map(transform: (Int) -> R): List<R> {
/**
* Returns a list containing the results of applying the given [transform] function
* to each element in the original array.
*
* @sample samples.collections.Collections.Transformations.map
*/
public inline fun <R> LongArray.map(transform: (Long) -> R): List<R> {
return mapTo(ArrayList<R>(size), transform)
@@ -8797,6 +8807,8 @@ public inline fun <R> LongArray.map(transform: (Long) -> R): List<R> {
/**
* Returns a list containing the results of applying the given [transform] function
* to each element in the original array.
*
* @sample samples.collections.Collections.Transformations.map
*/
public inline fun <R> FloatArray.map(transform: (Float) -> R): List<R> {
return mapTo(ArrayList<R>(size), transform)
@@ -8805,6 +8817,8 @@ public inline fun <R> FloatArray.map(transform: (Float) -> R): List<R> {
/**
* Returns a list containing the results of applying the given [transform] function
* to each element in the original array.
*
* @sample samples.collections.Collections.Transformations.map
*/
public inline fun <R> DoubleArray.map(transform: (Double) -> R): List<R> {
return mapTo(ArrayList<R>(size), transform)
@@ -8813,6 +8827,8 @@ public inline fun <R> DoubleArray.map(transform: (Double) -> R): List<R> {
/**
* Returns a list containing the results of applying the given [transform] function
* to each element in the original array.
*
* @sample samples.collections.Collections.Transformations.map
*/
public inline fun <R> BooleanArray.map(transform: (Boolean) -> R): List<R> {
return mapTo(ArrayList<R>(size), transform)
@@ -8821,6 +8837,8 @@ public inline fun <R> BooleanArray.map(transform: (Boolean) -> R): List<R> {
/**
* Returns a list containing the results of applying the given [transform] function
* to each element in the original array.
*
* @sample samples.collections.Collections.Transformations.map
*/
public inline fun <R> CharArray.map(transform: (Char) -> R): List<R> {
return mapTo(ArrayList<R>(size), transform)