Add samples for take* and drop* extensions (KT-20357)
- Add samples for take, takeLast, takeWhile, takeLastWhile - Add samples for drop, dropLast, dropWhile, dropLastWhile
This commit is contained in:
committed by
Ilya Gorbunov
parent
fda40723dc
commit
1c1fe10e12
@@ -2522,6 +2522,8 @@ public inline fun CharArray.singleOrNull(predicate: (Char) -> Boolean): Char? {
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except first [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public fun <T> Array<out T>.drop(n: Int): List<T> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -2530,6 +2532,8 @@ public fun <T> Array<out T>.drop(n: Int): List<T> {
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except first [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public fun ByteArray.drop(n: Int): List<Byte> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -2538,6 +2542,8 @@ public fun ByteArray.drop(n: Int): List<Byte> {
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except first [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public fun ShortArray.drop(n: Int): List<Short> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -2546,6 +2552,8 @@ public fun ShortArray.drop(n: Int): List<Short> {
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except first [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public fun IntArray.drop(n: Int): List<Int> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -2554,6 +2562,8 @@ public fun IntArray.drop(n: Int): List<Int> {
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except first [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public fun LongArray.drop(n: Int): List<Long> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -2562,6 +2572,8 @@ public fun LongArray.drop(n: Int): List<Long> {
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except first [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public fun FloatArray.drop(n: Int): List<Float> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -2570,6 +2582,8 @@ public fun FloatArray.drop(n: Int): List<Float> {
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except first [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public fun DoubleArray.drop(n: Int): List<Double> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -2578,6 +2592,8 @@ public fun DoubleArray.drop(n: Int): List<Double> {
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except first [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public fun BooleanArray.drop(n: Int): List<Boolean> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -2586,6 +2602,8 @@ public fun BooleanArray.drop(n: Int): List<Boolean> {
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except first [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public fun CharArray.drop(n: Int): List<Char> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -2594,6 +2612,8 @@ public fun CharArray.drop(n: Int): List<Char> {
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except last [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public fun <T> Array<out T>.dropLast(n: Int): List<T> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -2602,6 +2622,8 @@ public fun <T> Array<out T>.dropLast(n: Int): List<T> {
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except last [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public fun ByteArray.dropLast(n: Int): List<Byte> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -2610,6 +2632,8 @@ public fun ByteArray.dropLast(n: Int): List<Byte> {
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except last [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public fun ShortArray.dropLast(n: Int): List<Short> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -2618,6 +2642,8 @@ public fun ShortArray.dropLast(n: Int): List<Short> {
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except last [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public fun IntArray.dropLast(n: Int): List<Int> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -2626,6 +2652,8 @@ public fun IntArray.dropLast(n: Int): List<Int> {
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except last [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public fun LongArray.dropLast(n: Int): List<Long> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -2634,6 +2662,8 @@ public fun LongArray.dropLast(n: Int): List<Long> {
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except last [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public fun FloatArray.dropLast(n: Int): List<Float> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -2642,6 +2672,8 @@ public fun FloatArray.dropLast(n: Int): List<Float> {
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except last [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public fun DoubleArray.dropLast(n: Int): List<Double> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -2650,6 +2682,8 @@ public fun DoubleArray.dropLast(n: Int): List<Double> {
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except last [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public fun BooleanArray.dropLast(n: Int): List<Boolean> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -2658,6 +2692,8 @@ public fun BooleanArray.dropLast(n: Int): List<Boolean> {
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except last [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public fun CharArray.dropLast(n: Int): List<Char> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -2666,6 +2702,8 @@ public fun CharArray.dropLast(n: Int): List<Char> {
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except last elements that satisfy the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public inline fun <T> Array<out T>.dropLastWhile(predicate: (T) -> Boolean): List<T> {
|
||||
for (index in lastIndex downTo 0) {
|
||||
@@ -2678,6 +2716,8 @@ public inline fun <T> Array<out T>.dropLastWhile(predicate: (T) -> Boolean): Lis
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except last elements that satisfy the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public inline fun ByteArray.dropLastWhile(predicate: (Byte) -> Boolean): List<Byte> {
|
||||
for (index in lastIndex downTo 0) {
|
||||
@@ -2690,6 +2730,8 @@ public inline fun ByteArray.dropLastWhile(predicate: (Byte) -> Boolean): List<By
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except last elements that satisfy the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public inline fun ShortArray.dropLastWhile(predicate: (Short) -> Boolean): List<Short> {
|
||||
for (index in lastIndex downTo 0) {
|
||||
@@ -2702,6 +2744,8 @@ public inline fun ShortArray.dropLastWhile(predicate: (Short) -> Boolean): List<
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except last elements that satisfy the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public inline fun IntArray.dropLastWhile(predicate: (Int) -> Boolean): List<Int> {
|
||||
for (index in lastIndex downTo 0) {
|
||||
@@ -2714,6 +2758,8 @@ public inline fun IntArray.dropLastWhile(predicate: (Int) -> Boolean): List<Int>
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except last elements that satisfy the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public inline fun LongArray.dropLastWhile(predicate: (Long) -> Boolean): List<Long> {
|
||||
for (index in lastIndex downTo 0) {
|
||||
@@ -2726,6 +2772,8 @@ public inline fun LongArray.dropLastWhile(predicate: (Long) -> Boolean): List<Lo
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except last elements that satisfy the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public inline fun FloatArray.dropLastWhile(predicate: (Float) -> Boolean): List<Float> {
|
||||
for (index in lastIndex downTo 0) {
|
||||
@@ -2738,6 +2786,8 @@ public inline fun FloatArray.dropLastWhile(predicate: (Float) -> Boolean): List<
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except last elements that satisfy the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public inline fun DoubleArray.dropLastWhile(predicate: (Double) -> Boolean): List<Double> {
|
||||
for (index in lastIndex downTo 0) {
|
||||
@@ -2750,6 +2800,8 @@ public inline fun DoubleArray.dropLastWhile(predicate: (Double) -> Boolean): Lis
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except last elements that satisfy the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public inline fun BooleanArray.dropLastWhile(predicate: (Boolean) -> Boolean): List<Boolean> {
|
||||
for (index in lastIndex downTo 0) {
|
||||
@@ -2762,6 +2814,8 @@ public inline fun BooleanArray.dropLastWhile(predicate: (Boolean) -> Boolean): L
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except last elements that satisfy the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public inline fun CharArray.dropLastWhile(predicate: (Char) -> Boolean): List<Char> {
|
||||
for (index in lastIndex downTo 0) {
|
||||
@@ -2774,6 +2828,8 @@ public inline fun CharArray.dropLastWhile(predicate: (Char) -> Boolean): List<Ch
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except first elements that satisfy the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public inline fun <T> Array<out T>.dropWhile(predicate: (T) -> Boolean): List<T> {
|
||||
var yielding = false
|
||||
@@ -2790,6 +2846,8 @@ public inline fun <T> Array<out T>.dropWhile(predicate: (T) -> Boolean): List<T>
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except first elements that satisfy the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public inline fun ByteArray.dropWhile(predicate: (Byte) -> Boolean): List<Byte> {
|
||||
var yielding = false
|
||||
@@ -2806,6 +2864,8 @@ public inline fun ByteArray.dropWhile(predicate: (Byte) -> Boolean): List<Byte>
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except first elements that satisfy the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public inline fun ShortArray.dropWhile(predicate: (Short) -> Boolean): List<Short> {
|
||||
var yielding = false
|
||||
@@ -2822,6 +2882,8 @@ public inline fun ShortArray.dropWhile(predicate: (Short) -> Boolean): List<Shor
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except first elements that satisfy the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public inline fun IntArray.dropWhile(predicate: (Int) -> Boolean): List<Int> {
|
||||
var yielding = false
|
||||
@@ -2838,6 +2900,8 @@ public inline fun IntArray.dropWhile(predicate: (Int) -> Boolean): List<Int> {
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except first elements that satisfy the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public inline fun LongArray.dropWhile(predicate: (Long) -> Boolean): List<Long> {
|
||||
var yielding = false
|
||||
@@ -2854,6 +2918,8 @@ public inline fun LongArray.dropWhile(predicate: (Long) -> Boolean): List<Long>
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except first elements that satisfy the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public inline fun FloatArray.dropWhile(predicate: (Float) -> Boolean): List<Float> {
|
||||
var yielding = false
|
||||
@@ -2870,6 +2936,8 @@ public inline fun FloatArray.dropWhile(predicate: (Float) -> Boolean): List<Floa
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except first elements that satisfy the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public inline fun DoubleArray.dropWhile(predicate: (Double) -> Boolean): List<Double> {
|
||||
var yielding = false
|
||||
@@ -2886,6 +2954,8 @@ public inline fun DoubleArray.dropWhile(predicate: (Double) -> Boolean): List<Do
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except first elements that satisfy the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public inline fun BooleanArray.dropWhile(predicate: (Boolean) -> Boolean): List<Boolean> {
|
||||
var yielding = false
|
||||
@@ -2902,6 +2972,8 @@ public inline fun BooleanArray.dropWhile(predicate: (Boolean) -> Boolean): List<
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except first elements that satisfy the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public inline fun CharArray.dropWhile(predicate: (Char) -> Boolean): List<Char> {
|
||||
var yielding = false
|
||||
@@ -3792,6 +3864,8 @@ public fun CharArray.sliceArray(indices: IntRange): CharArray {
|
||||
|
||||
/**
|
||||
* Returns a list containing first [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public fun <T> Array<out T>.take(n: Int): List<T> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -3810,6 +3884,8 @@ public fun <T> Array<out T>.take(n: Int): List<T> {
|
||||
|
||||
/**
|
||||
* Returns a list containing first [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public fun ByteArray.take(n: Int): List<Byte> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -3828,6 +3904,8 @@ public fun ByteArray.take(n: Int): List<Byte> {
|
||||
|
||||
/**
|
||||
* Returns a list containing first [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public fun ShortArray.take(n: Int): List<Short> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -3846,6 +3924,8 @@ public fun ShortArray.take(n: Int): List<Short> {
|
||||
|
||||
/**
|
||||
* Returns a list containing first [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public fun IntArray.take(n: Int): List<Int> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -3864,6 +3944,8 @@ public fun IntArray.take(n: Int): List<Int> {
|
||||
|
||||
/**
|
||||
* Returns a list containing first [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public fun LongArray.take(n: Int): List<Long> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -3882,6 +3964,8 @@ public fun LongArray.take(n: Int): List<Long> {
|
||||
|
||||
/**
|
||||
* Returns a list containing first [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public fun FloatArray.take(n: Int): List<Float> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -3900,6 +3984,8 @@ public fun FloatArray.take(n: Int): List<Float> {
|
||||
|
||||
/**
|
||||
* Returns a list containing first [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public fun DoubleArray.take(n: Int): List<Double> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -3918,6 +4004,8 @@ public fun DoubleArray.take(n: Int): List<Double> {
|
||||
|
||||
/**
|
||||
* Returns a list containing first [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public fun BooleanArray.take(n: Int): List<Boolean> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -3936,6 +4024,8 @@ public fun BooleanArray.take(n: Int): List<Boolean> {
|
||||
|
||||
/**
|
||||
* Returns a list containing first [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public fun CharArray.take(n: Int): List<Char> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -3954,6 +4044,8 @@ public fun CharArray.take(n: Int): List<Char> {
|
||||
|
||||
/**
|
||||
* Returns a list containing last [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public fun <T> Array<out T>.takeLast(n: Int): List<T> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -3969,6 +4061,8 @@ public fun <T> Array<out T>.takeLast(n: Int): List<T> {
|
||||
|
||||
/**
|
||||
* Returns a list containing last [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public fun ByteArray.takeLast(n: Int): List<Byte> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -3984,6 +4078,8 @@ public fun ByteArray.takeLast(n: Int): List<Byte> {
|
||||
|
||||
/**
|
||||
* Returns a list containing last [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public fun ShortArray.takeLast(n: Int): List<Short> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -3999,6 +4095,8 @@ public fun ShortArray.takeLast(n: Int): List<Short> {
|
||||
|
||||
/**
|
||||
* Returns a list containing last [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public fun IntArray.takeLast(n: Int): List<Int> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -4014,6 +4112,8 @@ public fun IntArray.takeLast(n: Int): List<Int> {
|
||||
|
||||
/**
|
||||
* Returns a list containing last [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public fun LongArray.takeLast(n: Int): List<Long> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -4029,6 +4129,8 @@ public fun LongArray.takeLast(n: Int): List<Long> {
|
||||
|
||||
/**
|
||||
* Returns a list containing last [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public fun FloatArray.takeLast(n: Int): List<Float> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -4044,6 +4146,8 @@ public fun FloatArray.takeLast(n: Int): List<Float> {
|
||||
|
||||
/**
|
||||
* Returns a list containing last [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public fun DoubleArray.takeLast(n: Int): List<Double> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -4059,6 +4163,8 @@ public fun DoubleArray.takeLast(n: Int): List<Double> {
|
||||
|
||||
/**
|
||||
* Returns a list containing last [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public fun BooleanArray.takeLast(n: Int): List<Boolean> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -4074,6 +4180,8 @@ public fun BooleanArray.takeLast(n: Int): List<Boolean> {
|
||||
|
||||
/**
|
||||
* Returns a list containing last [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public fun CharArray.takeLast(n: Int): List<Char> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -4089,6 +4197,8 @@ public fun CharArray.takeLast(n: Int): List<Char> {
|
||||
|
||||
/**
|
||||
* Returns a list containing last elements satisfying the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public inline fun <T> Array<out T>.takeLastWhile(predicate: (T) -> Boolean): List<T> {
|
||||
for (index in lastIndex downTo 0) {
|
||||
@@ -4101,6 +4211,8 @@ public inline fun <T> Array<out T>.takeLastWhile(predicate: (T) -> Boolean): Lis
|
||||
|
||||
/**
|
||||
* Returns a list containing last elements satisfying the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public inline fun ByteArray.takeLastWhile(predicate: (Byte) -> Boolean): List<Byte> {
|
||||
for (index in lastIndex downTo 0) {
|
||||
@@ -4113,6 +4225,8 @@ public inline fun ByteArray.takeLastWhile(predicate: (Byte) -> Boolean): List<By
|
||||
|
||||
/**
|
||||
* Returns a list containing last elements satisfying the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public inline fun ShortArray.takeLastWhile(predicate: (Short) -> Boolean): List<Short> {
|
||||
for (index in lastIndex downTo 0) {
|
||||
@@ -4125,6 +4239,8 @@ public inline fun ShortArray.takeLastWhile(predicate: (Short) -> Boolean): List<
|
||||
|
||||
/**
|
||||
* Returns a list containing last elements satisfying the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public inline fun IntArray.takeLastWhile(predicate: (Int) -> Boolean): List<Int> {
|
||||
for (index in lastIndex downTo 0) {
|
||||
@@ -4137,6 +4253,8 @@ public inline fun IntArray.takeLastWhile(predicate: (Int) -> Boolean): List<Int>
|
||||
|
||||
/**
|
||||
* Returns a list containing last elements satisfying the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public inline fun LongArray.takeLastWhile(predicate: (Long) -> Boolean): List<Long> {
|
||||
for (index in lastIndex downTo 0) {
|
||||
@@ -4149,6 +4267,8 @@ public inline fun LongArray.takeLastWhile(predicate: (Long) -> Boolean): List<Lo
|
||||
|
||||
/**
|
||||
* Returns a list containing last elements satisfying the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public inline fun FloatArray.takeLastWhile(predicate: (Float) -> Boolean): List<Float> {
|
||||
for (index in lastIndex downTo 0) {
|
||||
@@ -4161,6 +4281,8 @@ public inline fun FloatArray.takeLastWhile(predicate: (Float) -> Boolean): List<
|
||||
|
||||
/**
|
||||
* Returns a list containing last elements satisfying the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public inline fun DoubleArray.takeLastWhile(predicate: (Double) -> Boolean): List<Double> {
|
||||
for (index in lastIndex downTo 0) {
|
||||
@@ -4173,6 +4295,8 @@ public inline fun DoubleArray.takeLastWhile(predicate: (Double) -> Boolean): Lis
|
||||
|
||||
/**
|
||||
* Returns a list containing last elements satisfying the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public inline fun BooleanArray.takeLastWhile(predicate: (Boolean) -> Boolean): List<Boolean> {
|
||||
for (index in lastIndex downTo 0) {
|
||||
@@ -4185,6 +4309,8 @@ public inline fun BooleanArray.takeLastWhile(predicate: (Boolean) -> Boolean): L
|
||||
|
||||
/**
|
||||
* Returns a list containing last elements satisfying the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public inline fun CharArray.takeLastWhile(predicate: (Char) -> Boolean): List<Char> {
|
||||
for (index in lastIndex downTo 0) {
|
||||
@@ -4197,6 +4323,8 @@ public inline fun CharArray.takeLastWhile(predicate: (Char) -> Boolean): List<Ch
|
||||
|
||||
/**
|
||||
* Returns a list containing first elements satisfying the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public inline fun <T> Array<out T>.takeWhile(predicate: (T) -> Boolean): List<T> {
|
||||
val list = ArrayList<T>()
|
||||
@@ -4210,6 +4338,8 @@ public inline fun <T> Array<out T>.takeWhile(predicate: (T) -> Boolean): List<T>
|
||||
|
||||
/**
|
||||
* Returns a list containing first elements satisfying the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public inline fun ByteArray.takeWhile(predicate: (Byte) -> Boolean): List<Byte> {
|
||||
val list = ArrayList<Byte>()
|
||||
@@ -4223,6 +4353,8 @@ public inline fun ByteArray.takeWhile(predicate: (Byte) -> Boolean): List<Byte>
|
||||
|
||||
/**
|
||||
* Returns a list containing first elements satisfying the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public inline fun ShortArray.takeWhile(predicate: (Short) -> Boolean): List<Short> {
|
||||
val list = ArrayList<Short>()
|
||||
@@ -4236,6 +4368,8 @@ public inline fun ShortArray.takeWhile(predicate: (Short) -> Boolean): List<Shor
|
||||
|
||||
/**
|
||||
* Returns a list containing first elements satisfying the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public inline fun IntArray.takeWhile(predicate: (Int) -> Boolean): List<Int> {
|
||||
val list = ArrayList<Int>()
|
||||
@@ -4249,6 +4383,8 @@ public inline fun IntArray.takeWhile(predicate: (Int) -> Boolean): List<Int> {
|
||||
|
||||
/**
|
||||
* Returns a list containing first elements satisfying the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public inline fun LongArray.takeWhile(predicate: (Long) -> Boolean): List<Long> {
|
||||
val list = ArrayList<Long>()
|
||||
@@ -4262,6 +4398,8 @@ public inline fun LongArray.takeWhile(predicate: (Long) -> Boolean): List<Long>
|
||||
|
||||
/**
|
||||
* Returns a list containing first elements satisfying the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public inline fun FloatArray.takeWhile(predicate: (Float) -> Boolean): List<Float> {
|
||||
val list = ArrayList<Float>()
|
||||
@@ -4275,6 +4413,8 @@ public inline fun FloatArray.takeWhile(predicate: (Float) -> Boolean): List<Floa
|
||||
|
||||
/**
|
||||
* Returns a list containing first elements satisfying the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public inline fun DoubleArray.takeWhile(predicate: (Double) -> Boolean): List<Double> {
|
||||
val list = ArrayList<Double>()
|
||||
@@ -4288,6 +4428,8 @@ public inline fun DoubleArray.takeWhile(predicate: (Double) -> Boolean): List<Do
|
||||
|
||||
/**
|
||||
* Returns a list containing first elements satisfying the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public inline fun BooleanArray.takeWhile(predicate: (Boolean) -> Boolean): List<Boolean> {
|
||||
val list = ArrayList<Boolean>()
|
||||
@@ -4301,6 +4443,8 @@ public inline fun BooleanArray.takeWhile(predicate: (Boolean) -> Boolean): List<
|
||||
|
||||
/**
|
||||
* Returns a list containing first elements satisfying the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public inline fun CharArray.takeWhile(predicate: (Char) -> Boolean): List<Char> {
|
||||
val list = ArrayList<Char>()
|
||||
@@ -13610,7 +13754,7 @@ public fun <A : Appendable> CharArray.joinTo(buffer: A, separator: CharSequence
|
||||
*
|
||||
* If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit]
|
||||
* elements will be appended, followed by the [truncated] string (which defaults to "...").
|
||||
*
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.joinToString
|
||||
*/
|
||||
public fun <T> Array<out T>.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((T) -> CharSequence)? = null): String {
|
||||
@@ -13622,7 +13766,7 @@ public fun <T> Array<out T>.joinToString(separator: CharSequence = ", ", prefix:
|
||||
*
|
||||
* If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit]
|
||||
* elements will be appended, followed by the [truncated] string (which defaults to "...").
|
||||
*
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.joinToString
|
||||
*/
|
||||
public fun ByteArray.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Byte) -> CharSequence)? = null): String {
|
||||
@@ -13646,7 +13790,7 @@ public fun ShortArray.joinToString(separator: CharSequence = ", ", prefix: CharS
|
||||
*
|
||||
* If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit]
|
||||
* elements will be appended, followed by the [truncated] string (which defaults to "...").
|
||||
*
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.joinToString
|
||||
*/
|
||||
public fun IntArray.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Int) -> CharSequence)? = null): String {
|
||||
|
||||
@@ -537,6 +537,8 @@ public inline fun <T> Iterable<T>.singleOrNull(predicate: (T) -> Boolean): T? {
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except first [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public fun <T> Iterable<T>.drop(n: Int): List<T> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -572,6 +574,8 @@ public fun <T> Iterable<T>.drop(n: Int): List<T> {
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except last [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public fun <T> List<T>.dropLast(n: Int): List<T> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -580,6 +584,8 @@ public fun <T> List<T>.dropLast(n: Int): List<T> {
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except last elements that satisfy the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public inline fun <T> List<T>.dropLastWhile(predicate: (T) -> Boolean): List<T> {
|
||||
if (!isEmpty()) {
|
||||
@@ -595,6 +601,8 @@ public inline fun <T> List<T>.dropLastWhile(predicate: (T) -> Boolean): List<T>
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements except first elements that satisfy the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.drop
|
||||
*/
|
||||
public inline fun <T> Iterable<T>.dropWhile(predicate: (T) -> Boolean): List<T> {
|
||||
var yielding = false
|
||||
@@ -729,6 +737,8 @@ public fun <T> List<T>.slice(indices: Iterable<Int>): List<T> {
|
||||
|
||||
/**
|
||||
* Returns a list containing first [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public fun <T> Iterable<T>.take(n: Int): List<T> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -749,6 +759,8 @@ public fun <T> Iterable<T>.take(n: Int): List<T> {
|
||||
|
||||
/**
|
||||
* Returns a list containing last [n] elements.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public fun <T> List<T>.takeLast(n: Int): List<T> {
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
@@ -769,6 +781,8 @@ public fun <T> List<T>.takeLast(n: Int): List<T> {
|
||||
|
||||
/**
|
||||
* Returns a list containing last elements satisfying the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public inline fun <T> List<T>.takeLastWhile(predicate: (T) -> Boolean): List<T> {
|
||||
if (isEmpty())
|
||||
@@ -790,6 +804,8 @@ public inline fun <T> List<T>.takeLastWhile(predicate: (T) -> Boolean): List<T>
|
||||
|
||||
/**
|
||||
* Returns a list containing first elements satisfying the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
*/
|
||||
public inline fun <T> Iterable<T>.takeWhile(predicate: (T) -> Boolean): List<T> {
|
||||
val list = ArrayList<T>()
|
||||
@@ -2203,6 +2219,8 @@ public fun <T, A : Appendable> Iterable<T>.joinTo(buffer: A, separator: CharSequ
|
||||
*
|
||||
* If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit]
|
||||
* elements will be appended, followed by the [truncated] string (which defaults to "...").
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.joinToString
|
||||
*/
|
||||
public fun <T> Iterable<T>.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((T) -> CharSequence)? = null): String {
|
||||
return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString()
|
||||
|
||||
Reference in New Issue
Block a user