// NOTE this file is auto-generated from stdlib/src/kotlin/JavaIterablesLazy.kt package kotlin import kotlin.util.* import java.util.ArrayList import java.util.Collection import java.util.List // // This file contains methods which could have a lazy implementation for things like // Iterator or java.util.Iterator // // See [[GenerateStandardLib.kt]] for more details // /** * Returns a list containing all elements which match the given *predicate* * * @includeFunction ../../test/CollectionTest.kt filter */ inline fun Array.filter(predicate: (T) -> Boolean) : List = filterTo(ArrayList(), predicate) /** * Returns a list containing all elements which do not match the given predicate * * @includeFunction ../../test/CollectionTest.kt filterNot */ inline fun Array.filterNot(predicate: (T)-> Boolean) : List = filterNotTo(ArrayList(), predicate) /** * Returns a list containing all the non-*null* elements * * @includeFunction ../../test/CollectionTest.kt filterNotNull */ inline fun Array?.filterNotNull() : List = filterNotNullTo>(java.util.ArrayList()) /** * Returns the result of transforming each element to one or more values which are concatenated together into a single collection * * @includeFunction ../../test/CollectionTest.kt flatMap */ inline fun Array.flatMap(transform: (T)-> Collection) : Collection = flatMapTo(ArrayList(), transform) /** * Returns a list containing the first *n* elements * * @includeFunction ../../test/CollectionTest.kt take */ inline fun Array.take(n: Int): List { fun countTo(n: Int): (T) -> Boolean { var count = 0 return { ++count; count <= n } } return takeWhile(countTo(n)) } /** * Returns a list containing the first elements that satisfy the given *predicate* * * @includeFunction ../../test/CollectionTest.kt takeWhile */ inline fun Array.takeWhile(predicate: (T) -> Boolean): List = takeWhileTo(ArrayList(), predicate) /** * Creates a string from all the elements separated using the *separator* and using the given *prefix* and *postfix* if supplied * * @includeFunction ../../test/CollectionTest.kt join */ inline fun Array.join(separator: String, prefix: String = "", postfix: String = "") : String { val buffer = StringBuilder(prefix) var first = true for (element in this) { if (first) first = false else buffer.append(separator) buffer.append(element) } buffer.append(postfix) return buffer.toString().sure() }