From fc4340f0f71db5f8c4bf79edbaff0811788c7ad8 Mon Sep 17 00:00:00 2001 From: James Strachan Date: Wed, 23 May 2012 09:46:15 +0100 Subject: [PATCH] #KT-2067 Fixed --- .../src/generated/ArraysFromJLangIterables.kt | 14 +++++++++++++ .../generated/ArraysFromJLangIterablesLazy.kt | 20 +++++++++++++++++++ .../BooleanArraysFromJLangIterables.kt | 14 +++++++++++++ .../BooleanArraysFromJLangIterablesLazy.kt | 20 +++++++++++++++++++ .../generated/ByteArraysFromJLangIterables.kt | 14 +++++++++++++ .../ByteArraysFromJLangIterablesLazy.kt | 20 +++++++++++++++++++ .../generated/CharArraysFromJLangIterables.kt | 14 +++++++++++++ .../CharArraysFromJLangIterablesLazy.kt | 20 +++++++++++++++++++ .../DoubleArraysFromJLangIterables.kt | 14 +++++++++++++ .../DoubleArraysFromJLangIterablesLazy.kt | 20 +++++++++++++++++++ .../FloatArraysFromJLangIterables.kt | 14 +++++++++++++ .../FloatArraysFromJLangIterablesLazy.kt | 20 +++++++++++++++++++ .../generated/IntArraysFromJLangIterables.kt | 14 +++++++++++++ .../IntArraysFromJLangIterablesLazy.kt | 20 +++++++++++++++++++ .../JUtilIteratorsFromJLangIterables.kt | 14 +++++++++++++ .../generated/LongArraysFromJLangIterables.kt | 14 +++++++++++++ .../LongArraysFromJLangIterablesLazy.kt | 20 +++++++++++++++++++ .../ShortArraysFromJLangIterables.kt | 14 +++++++++++++ .../ShortArraysFromJLangIterablesLazy.kt | 20 +++++++++++++++++++ .../generated/StandardFromJLangIterables.kt | 14 +++++++++++++ .../StandardFromJLangIterablesLazy.kt | 20 +++++++++++++++++++ 21 files changed, 354 insertions(+) diff --git a/libraries/stdlib/src/generated/ArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/ArraysFromJLangIterables.kt index 2d370e35619..945ab1edda0 100644 --- a/libraries/stdlib/src/generated/ArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/ArraysFromJLangIterables.kt @@ -175,6 +175,20 @@ public inline fun Array.makeString(separator: String = ", ", prefix: Stri return buffer.toString().sure() } +/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */ +public inline fun > Array.dropWhileTo(result: L, predicate: (T) -> Boolean) : L { + var start = true + for (element in this) { + if (start && predicate(element)) { + // ignore + } else { + start = false + result.add(element) + } + } + return result +} + /** Returns a list containing the first elements that satisfy the given *predicate* */ public inline fun > Array.takeWhileTo(result: L, predicate: (T) -> Boolean) : L { for (element in this) if (predicate(element)) result.add(element) else break diff --git a/libraries/stdlib/src/generated/ArraysFromJLangIterablesLazy.kt b/libraries/stdlib/src/generated/ArraysFromJLangIterablesLazy.kt index 82a8c13afb7..7e6a0b1b01c 100644 --- a/libraries/stdlib/src/generated/ArraysFromJLangIterablesLazy.kt +++ b/libraries/stdlib/src/generated/ArraysFromJLangIterablesLazy.kt @@ -82,6 +82,26 @@ public inline fun Array?.requireNoNulls() : List { return list } +/** + * Returns a list containing everything but the first *n* elements + * + * @includeFunctionBody ../../test/CollectionTest.kt drop + */ +public inline fun Array.drop(n: Int): List { + fun countTo(n: Int): (T) -> Boolean { + var count = 0 + return { ++count; count <= n } + } + return dropWhile(countTo(n)) +} + +/** + * Returns a list containing the everything but the first elements that satisfy the given *predicate* + * + * @includeFunctionBody ../../test/CollectionTest.kt dropWhile + */ +public inline fun Array.dropWhile(predicate: (T) -> Boolean): List = dropWhileTo(ArrayList(), predicate) + /** * Returns a list containing the first *n* elements * diff --git a/libraries/stdlib/src/generated/BooleanArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/BooleanArraysFromJLangIterables.kt index 5a602b2773e..c0af7295f13 100644 --- a/libraries/stdlib/src/generated/BooleanArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/BooleanArraysFromJLangIterables.kt @@ -175,6 +175,20 @@ public inline fun BooleanArray.makeString(separator: String = ", ", prefix: Stri return buffer.toString().sure() } +/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */ +public inline fun > BooleanArray.dropWhileTo(result: L, predicate: (Boolean) -> Boolean) : L { + var start = true + for (element in this) { + if (start && predicate(element)) { + // ignore + } else { + start = false + result.add(element) + } + } + return result +} + /** Returns a list containing the first elements that satisfy the given *predicate* */ public inline fun > BooleanArray.takeWhileTo(result: L, predicate: (Boolean) -> Boolean) : L { for (element in this) if (predicate(element)) result.add(element) else break diff --git a/libraries/stdlib/src/generated/BooleanArraysFromJLangIterablesLazy.kt b/libraries/stdlib/src/generated/BooleanArraysFromJLangIterablesLazy.kt index 2b5046f565c..f3861ae081a 100644 --- a/libraries/stdlib/src/generated/BooleanArraysFromJLangIterablesLazy.kt +++ b/libraries/stdlib/src/generated/BooleanArraysFromJLangIterablesLazy.kt @@ -82,6 +82,26 @@ public inline fun BooleanArray?.requireNoNulls() : List { return list } +/** + * Returns a list containing everything but the first *n* elements + * + * @includeFunctionBody ../../test/CollectionTest.kt drop + */ +public inline fun BooleanArray.drop(n: Int): List { + fun countTo(n: Int): (Boolean) -> Boolean { + var count = 0 + return { ++count; count <= n } + } + return dropWhile(countTo(n)) +} + +/** + * Returns a list containing the everything but the first elements that satisfy the given *predicate* + * + * @includeFunctionBody ../../test/CollectionTest.kt dropWhile + */ +public inline fun BooleanArray.dropWhile(predicate: (Boolean) -> Boolean): List = dropWhileTo(ArrayList(), predicate) + /** * Returns a list containing the first *n* elements * diff --git a/libraries/stdlib/src/generated/ByteArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/ByteArraysFromJLangIterables.kt index 3188a83b549..4be696057d0 100644 --- a/libraries/stdlib/src/generated/ByteArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/ByteArraysFromJLangIterables.kt @@ -175,6 +175,20 @@ public inline fun ByteArray.makeString(separator: String = ", ", prefix: String return buffer.toString().sure() } +/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */ +public inline fun > ByteArray.dropWhileTo(result: L, predicate: (Byte) -> Boolean) : L { + var start = true + for (element in this) { + if (start && predicate(element)) { + // ignore + } else { + start = false + result.add(element) + } + } + return result +} + /** Returns a list containing the first elements that satisfy the given *predicate* */ public inline fun > ByteArray.takeWhileTo(result: L, predicate: (Byte) -> Boolean) : L { for (element in this) if (predicate(element)) result.add(element) else break diff --git a/libraries/stdlib/src/generated/ByteArraysFromJLangIterablesLazy.kt b/libraries/stdlib/src/generated/ByteArraysFromJLangIterablesLazy.kt index d2bd87e3822..dcc95aa37ee 100644 --- a/libraries/stdlib/src/generated/ByteArraysFromJLangIterablesLazy.kt +++ b/libraries/stdlib/src/generated/ByteArraysFromJLangIterablesLazy.kt @@ -82,6 +82,26 @@ public inline fun ByteArray?.requireNoNulls() : List { return list } +/** + * Returns a list containing everything but the first *n* elements + * + * @includeFunctionBody ../../test/CollectionTest.kt drop + */ +public inline fun ByteArray.drop(n: Int): List { + fun countTo(n: Int): (Byte) -> Boolean { + var count = 0 + return { ++count; count <= n } + } + return dropWhile(countTo(n)) +} + +/** + * Returns a list containing the everything but the first elements that satisfy the given *predicate* + * + * @includeFunctionBody ../../test/CollectionTest.kt dropWhile + */ +public inline fun ByteArray.dropWhile(predicate: (Byte) -> Boolean): List = dropWhileTo(ArrayList(), predicate) + /** * Returns a list containing the first *n* elements * diff --git a/libraries/stdlib/src/generated/CharArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/CharArraysFromJLangIterables.kt index 1206ff7c23b..5ad686bdd59 100644 --- a/libraries/stdlib/src/generated/CharArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/CharArraysFromJLangIterables.kt @@ -175,6 +175,20 @@ public inline fun CharArray.makeString(separator: String = ", ", prefix: String return buffer.toString().sure() } +/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */ +public inline fun > CharArray.dropWhileTo(result: L, predicate: (Char) -> Boolean) : L { + var start = true + for (element in this) { + if (start && predicate(element)) { + // ignore + } else { + start = false + result.add(element) + } + } + return result +} + /** Returns a list containing the first elements that satisfy the given *predicate* */ public inline fun > CharArray.takeWhileTo(result: L, predicate: (Char) -> Boolean) : L { for (element in this) if (predicate(element)) result.add(element) else break diff --git a/libraries/stdlib/src/generated/CharArraysFromJLangIterablesLazy.kt b/libraries/stdlib/src/generated/CharArraysFromJLangIterablesLazy.kt index 896aa1df647..fde5a0ebc0c 100644 --- a/libraries/stdlib/src/generated/CharArraysFromJLangIterablesLazy.kt +++ b/libraries/stdlib/src/generated/CharArraysFromJLangIterablesLazy.kt @@ -82,6 +82,26 @@ public inline fun CharArray?.requireNoNulls() : List { return list } +/** + * Returns a list containing everything but the first *n* elements + * + * @includeFunctionBody ../../test/CollectionTest.kt drop + */ +public inline fun CharArray.drop(n: Int): List { + fun countTo(n: Int): (Char) -> Boolean { + var count = 0 + return { ++count; count <= n } + } + return dropWhile(countTo(n)) +} + +/** + * Returns a list containing the everything but the first elements that satisfy the given *predicate* + * + * @includeFunctionBody ../../test/CollectionTest.kt dropWhile + */ +public inline fun CharArray.dropWhile(predicate: (Char) -> Boolean): List = dropWhileTo(ArrayList(), predicate) + /** * Returns a list containing the first *n* elements * diff --git a/libraries/stdlib/src/generated/DoubleArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/DoubleArraysFromJLangIterables.kt index dd7ace59644..fc0cff9fff2 100644 --- a/libraries/stdlib/src/generated/DoubleArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/DoubleArraysFromJLangIterables.kt @@ -175,6 +175,20 @@ public inline fun DoubleArray.makeString(separator: String = ", ", prefix: Strin return buffer.toString().sure() } +/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */ +public inline fun > DoubleArray.dropWhileTo(result: L, predicate: (Double) -> Boolean) : L { + var start = true + for (element in this) { + if (start && predicate(element)) { + // ignore + } else { + start = false + result.add(element) + } + } + return result +} + /** Returns a list containing the first elements that satisfy the given *predicate* */ public inline fun > DoubleArray.takeWhileTo(result: L, predicate: (Double) -> Boolean) : L { for (element in this) if (predicate(element)) result.add(element) else break diff --git a/libraries/stdlib/src/generated/DoubleArraysFromJLangIterablesLazy.kt b/libraries/stdlib/src/generated/DoubleArraysFromJLangIterablesLazy.kt index e5f9bb5bae4..358b041eb11 100644 --- a/libraries/stdlib/src/generated/DoubleArraysFromJLangIterablesLazy.kt +++ b/libraries/stdlib/src/generated/DoubleArraysFromJLangIterablesLazy.kt @@ -82,6 +82,26 @@ public inline fun DoubleArray?.requireNoNulls() : List { return list } +/** + * Returns a list containing everything but the first *n* elements + * + * @includeFunctionBody ../../test/CollectionTest.kt drop + */ +public inline fun DoubleArray.drop(n: Int): List { + fun countTo(n: Int): (Double) -> Boolean { + var count = 0 + return { ++count; count <= n } + } + return dropWhile(countTo(n)) +} + +/** + * Returns a list containing the everything but the first elements that satisfy the given *predicate* + * + * @includeFunctionBody ../../test/CollectionTest.kt dropWhile + */ +public inline fun DoubleArray.dropWhile(predicate: (Double) -> Boolean): List = dropWhileTo(ArrayList(), predicate) + /** * Returns a list containing the first *n* elements * diff --git a/libraries/stdlib/src/generated/FloatArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/FloatArraysFromJLangIterables.kt index faa3b25d640..fe063e64180 100644 --- a/libraries/stdlib/src/generated/FloatArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/FloatArraysFromJLangIterables.kt @@ -175,6 +175,20 @@ public inline fun FloatArray.makeString(separator: String = ", ", prefix: String return buffer.toString().sure() } +/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */ +public inline fun > FloatArray.dropWhileTo(result: L, predicate: (Float) -> Boolean) : L { + var start = true + for (element in this) { + if (start && predicate(element)) { + // ignore + } else { + start = false + result.add(element) + } + } + return result +} + /** Returns a list containing the first elements that satisfy the given *predicate* */ public inline fun > FloatArray.takeWhileTo(result: L, predicate: (Float) -> Boolean) : L { for (element in this) if (predicate(element)) result.add(element) else break diff --git a/libraries/stdlib/src/generated/FloatArraysFromJLangIterablesLazy.kt b/libraries/stdlib/src/generated/FloatArraysFromJLangIterablesLazy.kt index cb97842e2c1..e1ab86e73a3 100644 --- a/libraries/stdlib/src/generated/FloatArraysFromJLangIterablesLazy.kt +++ b/libraries/stdlib/src/generated/FloatArraysFromJLangIterablesLazy.kt @@ -82,6 +82,26 @@ public inline fun FloatArray?.requireNoNulls() : List { return list } +/** + * Returns a list containing everything but the first *n* elements + * + * @includeFunctionBody ../../test/CollectionTest.kt drop + */ +public inline fun FloatArray.drop(n: Int): List { + fun countTo(n: Int): (Float) -> Boolean { + var count = 0 + return { ++count; count <= n } + } + return dropWhile(countTo(n)) +} + +/** + * Returns a list containing the everything but the first elements that satisfy the given *predicate* + * + * @includeFunctionBody ../../test/CollectionTest.kt dropWhile + */ +public inline fun FloatArray.dropWhile(predicate: (Float) -> Boolean): List = dropWhileTo(ArrayList(), predicate) + /** * Returns a list containing the first *n* elements * diff --git a/libraries/stdlib/src/generated/IntArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/IntArraysFromJLangIterables.kt index c971a10989a..cc913519a9e 100644 --- a/libraries/stdlib/src/generated/IntArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/IntArraysFromJLangIterables.kt @@ -175,6 +175,20 @@ public inline fun IntArray.makeString(separator: String = ", ", prefix: String = return buffer.toString().sure() } +/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */ +public inline fun > IntArray.dropWhileTo(result: L, predicate: (Int) -> Boolean) : L { + var start = true + for (element in this) { + if (start && predicate(element)) { + // ignore + } else { + start = false + result.add(element) + } + } + return result +} + /** Returns a list containing the first elements that satisfy the given *predicate* */ public inline fun > IntArray.takeWhileTo(result: L, predicate: (Int) -> Boolean) : L { for (element in this) if (predicate(element)) result.add(element) else break diff --git a/libraries/stdlib/src/generated/IntArraysFromJLangIterablesLazy.kt b/libraries/stdlib/src/generated/IntArraysFromJLangIterablesLazy.kt index ab8e2b72057..312f30484de 100644 --- a/libraries/stdlib/src/generated/IntArraysFromJLangIterablesLazy.kt +++ b/libraries/stdlib/src/generated/IntArraysFromJLangIterablesLazy.kt @@ -82,6 +82,26 @@ public inline fun IntArray?.requireNoNulls() : List { return list } +/** + * Returns a list containing everything but the first *n* elements + * + * @includeFunctionBody ../../test/CollectionTest.kt drop + */ +public inline fun IntArray.drop(n: Int): List { + fun countTo(n: Int): (Int) -> Boolean { + var count = 0 + return { ++count; count <= n } + } + return dropWhile(countTo(n)) +} + +/** + * Returns a list containing the everything but the first elements that satisfy the given *predicate* + * + * @includeFunctionBody ../../test/CollectionTest.kt dropWhile + */ +public inline fun IntArray.dropWhile(predicate: (Int) -> Boolean): List = dropWhileTo(ArrayList(), predicate) + /** * Returns a list containing the first *n* elements * diff --git a/libraries/stdlib/src/generated/JUtilIteratorsFromJLangIterables.kt b/libraries/stdlib/src/generated/JUtilIteratorsFromJLangIterables.kt index 3e3b1c39591..6730c21d84f 100644 --- a/libraries/stdlib/src/generated/JUtilIteratorsFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/JUtilIteratorsFromJLangIterables.kt @@ -173,6 +173,20 @@ public inline fun java.util.Iterator.makeString(separator: String = ", ", return buffer.toString().sure() } +/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */ +public inline fun > java.util.Iterator.dropWhileTo(result: L, predicate: (T) -> Boolean) : L { + var start = true + for (element in this) { + if (start && predicate(element)) { + // ignore + } else { + start = false + result.add(element) + } + } + return result +} + /** Returns a list containing the first elements that satisfy the given *predicate* */ public inline fun > java.util.Iterator.takeWhileTo(result: L, predicate: (T) -> Boolean) : L { for (element in this) if (predicate(element)) result.add(element) else break diff --git a/libraries/stdlib/src/generated/LongArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/LongArraysFromJLangIterables.kt index 42f24d0fcf0..421f238abf1 100644 --- a/libraries/stdlib/src/generated/LongArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/LongArraysFromJLangIterables.kt @@ -175,6 +175,20 @@ public inline fun LongArray.makeString(separator: String = ", ", prefix: String return buffer.toString().sure() } +/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */ +public inline fun > LongArray.dropWhileTo(result: L, predicate: (Long) -> Boolean) : L { + var start = true + for (element in this) { + if (start && predicate(element)) { + // ignore + } else { + start = false + result.add(element) + } + } + return result +} + /** Returns a list containing the first elements that satisfy the given *predicate* */ public inline fun > LongArray.takeWhileTo(result: L, predicate: (Long) -> Boolean) : L { for (element in this) if (predicate(element)) result.add(element) else break diff --git a/libraries/stdlib/src/generated/LongArraysFromJLangIterablesLazy.kt b/libraries/stdlib/src/generated/LongArraysFromJLangIterablesLazy.kt index e9b6ec4fae3..dd1aa5ef82f 100644 --- a/libraries/stdlib/src/generated/LongArraysFromJLangIterablesLazy.kt +++ b/libraries/stdlib/src/generated/LongArraysFromJLangIterablesLazy.kt @@ -82,6 +82,26 @@ public inline fun LongArray?.requireNoNulls() : List { return list } +/** + * Returns a list containing everything but the first *n* elements + * + * @includeFunctionBody ../../test/CollectionTest.kt drop + */ +public inline fun LongArray.drop(n: Int): List { + fun countTo(n: Int): (Long) -> Boolean { + var count = 0 + return { ++count; count <= n } + } + return dropWhile(countTo(n)) +} + +/** + * Returns a list containing the everything but the first elements that satisfy the given *predicate* + * + * @includeFunctionBody ../../test/CollectionTest.kt dropWhile + */ +public inline fun LongArray.dropWhile(predicate: (Long) -> Boolean): List = dropWhileTo(ArrayList(), predicate) + /** * Returns a list containing the first *n* elements * diff --git a/libraries/stdlib/src/generated/ShortArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/ShortArraysFromJLangIterables.kt index da763e49581..1162088f2f1 100644 --- a/libraries/stdlib/src/generated/ShortArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/ShortArraysFromJLangIterables.kt @@ -175,6 +175,20 @@ public inline fun ShortArray.makeString(separator: String = ", ", prefix: String return buffer.toString().sure() } +/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */ +public inline fun > ShortArray.dropWhileTo(result: L, predicate: (Short) -> Boolean) : L { + var start = true + for (element in this) { + if (start && predicate(element)) { + // ignore + } else { + start = false + result.add(element) + } + } + return result +} + /** Returns a list containing the first elements that satisfy the given *predicate* */ public inline fun > ShortArray.takeWhileTo(result: L, predicate: (Short) -> Boolean) : L { for (element in this) if (predicate(element)) result.add(element) else break diff --git a/libraries/stdlib/src/generated/ShortArraysFromJLangIterablesLazy.kt b/libraries/stdlib/src/generated/ShortArraysFromJLangIterablesLazy.kt index 28d3b41795a..f0ca49a9177 100644 --- a/libraries/stdlib/src/generated/ShortArraysFromJLangIterablesLazy.kt +++ b/libraries/stdlib/src/generated/ShortArraysFromJLangIterablesLazy.kt @@ -82,6 +82,26 @@ public inline fun ShortArray?.requireNoNulls() : List { return list } +/** + * Returns a list containing everything but the first *n* elements + * + * @includeFunctionBody ../../test/CollectionTest.kt drop + */ +public inline fun ShortArray.drop(n: Int): List { + fun countTo(n: Int): (Short) -> Boolean { + var count = 0 + return { ++count; count <= n } + } + return dropWhile(countTo(n)) +} + +/** + * Returns a list containing the everything but the first elements that satisfy the given *predicate* + * + * @includeFunctionBody ../../test/CollectionTest.kt dropWhile + */ +public inline fun ShortArray.dropWhile(predicate: (Short) -> Boolean): List = dropWhileTo(ArrayList(), predicate) + /** * Returns a list containing the first *n* elements * diff --git a/libraries/stdlib/src/generated/StandardFromJLangIterables.kt b/libraries/stdlib/src/generated/StandardFromJLangIterables.kt index e9684b9457e..f85b9bd81d5 100644 --- a/libraries/stdlib/src/generated/StandardFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/StandardFromJLangIterables.kt @@ -175,6 +175,20 @@ public inline fun Iterable.makeString(separator: String = ", ", prefix: S return buffer.toString().sure() } +/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */ +public inline fun > Iterable.dropWhileTo(result: L, predicate: (T) -> Boolean) : L { + var start = true + for (element in this) { + if (start && predicate(element)) { + // ignore + } else { + start = false + result.add(element) + } + } + return result +} + /** Returns a list containing the first elements that satisfy the given *predicate* */ public inline fun > Iterable.takeWhileTo(result: L, predicate: (T) -> Boolean) : L { for (element in this) if (predicate(element)) result.add(element) else break diff --git a/libraries/stdlib/src/generated/StandardFromJLangIterablesLazy.kt b/libraries/stdlib/src/generated/StandardFromJLangIterablesLazy.kt index 65c3248dc2b..319c0748abc 100644 --- a/libraries/stdlib/src/generated/StandardFromJLangIterablesLazy.kt +++ b/libraries/stdlib/src/generated/StandardFromJLangIterablesLazy.kt @@ -82,6 +82,26 @@ public inline fun Iterable?.requireNoNulls() : List { return list } +/** + * Returns a list containing everything but the first *n* elements + * + * @includeFunctionBody ../../test/CollectionTest.kt drop + */ +public inline fun Iterable.drop(n: Int): List { + fun countTo(n: Int): (T) -> Boolean { + var count = 0 + return { ++count; count <= n } + } + return dropWhile(countTo(n)) +} + +/** + * Returns a list containing the everything but the first elements that satisfy the given *predicate* + * + * @includeFunctionBody ../../test/CollectionTest.kt dropWhile + */ +public inline fun Iterable.dropWhile(predicate: (T) -> Boolean): List = dropWhileTo(ArrayList(), predicate) + /** * Returns a list containing the first *n* elements *