From 4ba851f5c5e27e422e2c88d92f29d9ab21e4f9a0 Mon Sep 17 00:00:00 2001 From: James Strachan Date: Tue, 3 Apr 2012 15:51:33 +0100 Subject: [PATCH] #KT-1391 Fixed --- .../generated/ArraysFromJLangIterablesLazy.kt | 23 +++++++++++++++++++ .../StandardFromJLangIterablesLazy.kt | 23 +++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/libraries/stdlib/src/generated/ArraysFromJLangIterablesLazy.kt b/libraries/stdlib/src/generated/ArraysFromJLangIterablesLazy.kt index f3bbcbc9cba..6bd375e692c 100644 --- a/libraries/stdlib/src/generated/ArraysFromJLangIterablesLazy.kt +++ b/libraries/stdlib/src/generated/ArraysFromJLangIterablesLazy.kt @@ -42,6 +42,29 @@ public inline fun Array?.filterNotNull() : List = filterNotNullTo Array.flatMap(transform: (T)-> Collection) : Collection = flatMapTo(ArrayList(), transform) +/** + * Creates a copy of this collection as a [[List]] with the element added at the end + * + * @includeFunctionBody ../../test/CollectionTest.kt plus + */ +public inline fun Array.plus(element: T): List { + val list = to(ArrayList()) + list.add(element) + return list +} + + +/** + * Creates a copy of this collection as a [[List]] with all the elements added at the end + * + * @includeFunctionBody ../../test/CollectionTest.kt plusCollection + */ +public inline fun Array.plus(elements: Array): List { + val list = to(ArrayList()) + list.addAll(elements.toCollection()) + return list +} + /** * Returns a list containing all the non-*null* elements, throwing an [[IllegalArgumentException]] if there are any null elements * diff --git a/libraries/stdlib/src/generated/StandardFromJLangIterablesLazy.kt b/libraries/stdlib/src/generated/StandardFromJLangIterablesLazy.kt index 3fbfefb60fd..da63be3f6c9 100644 --- a/libraries/stdlib/src/generated/StandardFromJLangIterablesLazy.kt +++ b/libraries/stdlib/src/generated/StandardFromJLangIterablesLazy.kt @@ -42,6 +42,29 @@ public inline fun Iterable?.filterNotNull() : List = filterNotNullTo< */ public inline fun Iterable.flatMap(transform: (T)-> Collection) : Collection = flatMapTo(ArrayList(), transform) +/** + * Creates a copy of this collection as a [[List]] with the element added at the end + * + * @includeFunctionBody ../../test/CollectionTest.kt plus + */ +public inline fun Iterable.plus(element: T): List { + val list = to(ArrayList()) + list.add(element) + return list +} + + +/** + * Creates a copy of this collection as a [[List]] with all the elements added at the end + * + * @includeFunctionBody ../../test/CollectionTest.kt plusCollection + */ +public inline fun Iterable.plus(elements: Iterable): List { + val list = to(ArrayList()) + list.addAll(elements.toCollection()) + return list +} + /** * Returns a list containing all the non-*null* elements, throwing an [[IllegalArgumentException]] if there are any null elements *