Merge pull request #48 from Frostman/iter-impr

Small iterables improvement
This commit is contained in:
James Strachan
2012-06-15 03:15:42 -07:00
12 changed files with 36 additions and 36 deletions
@@ -90,7 +90,7 @@ public inline fun <C: Collection<Double>> DoubleArray.filterTo(result: C, predic
*
* @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList
*/
public inline fun <L: List<Double>> DoubleArray.filterNotTo(result: L, predicate: (Double) -> Boolean) : L {
public inline fun <C: Collection<Double>> DoubleArray.filterNotTo(result: C, predicate: (Double) -> Boolean) : C {
for (element in this) if (!predicate(element)) result.add(element)
return result
}
@@ -100,7 +100,7 @@ public inline fun <L: List<Double>> DoubleArray.filterNotTo(result: L, predicate
*
* @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList
*/
public inline fun <L: List<Double>> DoubleArray?.filterNotNullTo(result: L) : L {
public inline fun <C: Collection<Double>> DoubleArray?.filterNotNullTo(result: C) : C {
if (this != null) {
for (element in this) if (element != null) result.add(element)
}
@@ -197,7 +197,7 @@ public inline fun <L: List<Double>> DoubleArray.dropWhileTo(result: L, predicate
}
/** Returns a list containing the first elements that satisfy the given *predicate* */
public inline fun <L: List<Double>> DoubleArray.takeWhileTo(result: L, predicate: (Double) -> Boolean) : L {
public inline fun <C: Collection<Double>> DoubleArray.takeWhileTo(result: C, predicate: (Double) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element) else break
return result
}