Add samples for zip on arrays and collections

Write the sample references in the template and run the generator
This commit is contained in:
TakuyaKodama
2018-04-15 01:42:01 +09:00
committed by Ilya Gorbunov
parent 137698d967
commit 2d4e591b5d
4 changed files with 138 additions and 1 deletions
@@ -2086,6 +2086,8 @@ public fun <T, R> Iterable<T>.windowed(size: Int, step: Int = 1, partialWindows:
/**
* Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection.
*
* @sample samples.collections.Iterables.Operations.zipIterable
*/
public infix fun <T, R> Iterable<T>.zip(other: Array<out R>): List<Pair<T, R>> {
return zip(other) { t1, t2 -> t1 to t2 }
@@ -2093,6 +2095,8 @@ public infix fun <T, R> Iterable<T>.zip(other: Array<out R>): List<Pair<T, R>> {
/**
* Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection.
*
* @sample samples.collections.Iterables.Operations.zipIterableWithTransform
*/
public inline fun <T, R, V> Iterable<T>.zip(other: Array<out R>, transform: (a: T, b: R) -> V): List<V> {
val arraySize = other.size
@@ -2107,6 +2111,8 @@ public inline fun <T, R, V> Iterable<T>.zip(other: Array<out R>, transform: (a:
/**
* Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection.
*
* @sample samples.collections.Iterables.Operations.zipIterable
*/
public infix fun <T, R> Iterable<T>.zip(other: Iterable<R>): List<Pair<T, R>> {
return zip(other) { t1, t2 -> t1 to t2 }
@@ -2114,6 +2120,8 @@ public infix fun <T, R> Iterable<T>.zip(other: Iterable<R>): List<Pair<T, R>> {
/**
* Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection.
*
* @sample samples.collections.Iterables.Operations.zipIterableWithTransform
*/
public inline fun <T, R, V> Iterable<T>.zip(other: Iterable<R>, transform: (a: T, b: R) -> V): List<V> {
val first = iterator()