List<T> replaced with Collection<T> in JLangIterables where it is possible

This commit is contained in:
Sergey Lukjanov
2012-05-04 17:58:15 +04:00
parent 652b9e78c3
commit 58b65360b1
@@ -80,7 +80,7 @@ public inline fun <T, C: Collection<in T>> java.lang.Iterable<T>.filterTo(result
* *
* @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList * @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList
*/ */
public inline fun <T, L: List<in T>> java.lang.Iterable<T>.filterNotTo(result: L, predicate: (T) -> Boolean) : L { public inline fun <T, C: Collection<in T>> java.lang.Iterable<T>.filterNotTo(result: C, predicate: (T) -> Boolean) : C {
for (element in this) if (!predicate(element)) result.add(element) for (element in this) if (!predicate(element)) result.add(element)
return result return result
} }
@@ -90,7 +90,7 @@ public inline fun <T, L: List<in T>> java.lang.Iterable<T>.filterNotTo(result: L
* *
* @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList * @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList
*/ */
public inline fun <T, L: List<in T>> java.lang.Iterable<T?>?.filterNotNullTo(result: L) : L { public inline fun <T, C: Collection<in T>> java.lang.Iterable<T?>?.filterNotNullTo(result: C) : C {
if (this != null) { if (this != null) {
for (element in this) if (element != null) result.add(element) for (element in this) if (element != null) result.add(element)
} }
@@ -173,7 +173,7 @@ public inline fun <T> java.lang.Iterable<T>.makeString(separator: String = ", ",
} }
/** Returns a list containing the first elements that satisfy the given *predicate* */ /** Returns a list containing the first elements that satisfy the given *predicate* */
public inline fun <T, L: List<in T>> java.lang.Iterable<T>.takeWhileTo(result: L, predicate: (T) -> Boolean) : L { public inline fun <T, C: Collection<in T>> java.lang.Iterable<T>.takeWhileTo(result: C, predicate: (T) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element) else break for (element in this) if (predicate(element)) result.add(element) else break
return result return result
} }