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 <T, C: Collection<in T>> Array<T>.filterTo(result: C, predicat
*
* @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList
*/
public inline fun <T, L: List<in T>> Array<T>.filterNotTo(result: L, predicate: (T) -> Boolean) : L {
public inline fun <T, C: Collection<in T>> Array<T>.filterNotTo(result: C, predicate: (T) -> Boolean) : C {
for (element in this) if (!predicate(element)) result.add(element)
return result
}
@@ -100,7 +100,7 @@ public inline fun <T, L: List<in T>> Array<T>.filterNotTo(result: L, predicate:
*
* @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList
*/
public inline fun <T, L: List<in T>> Array<T?>?.filterNotNullTo(result: L) : L {
public inline fun <T, C: Collection<in T>> Array<T?>?.filterNotNullTo(result: C) : C {
if (this != null) {
for (element in this) if (element != null) result.add(element)
}
@@ -197,7 +197,7 @@ public inline fun <T, L: List<in T>> Array<T>.dropWhileTo(result: L, predicate:
}
/** Returns a list containing the first elements that satisfy the given *predicate* */
public inline fun <T, L: List<in T>> Array<T>.takeWhileTo(result: L, predicate: (T) -> Boolean) : L {
public inline fun <T, C: Collection<in T>> Array<T>.takeWhileTo(result: C, predicate: (T) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element) else break
return result
}
@@ -90,7 +90,7 @@ public inline fun <C: Collection<Boolean>> BooleanArray.filterTo(result: C, pred
*
* @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList
*/
public inline fun <L: List<Boolean>> BooleanArray.filterNotTo(result: L, predicate: (Boolean) -> Boolean) : L {
public inline fun <C: Collection<Boolean>> BooleanArray.filterNotTo(result: C, predicate: (Boolean) -> Boolean) : C {
for (element in this) if (!predicate(element)) result.add(element)
return result
}
@@ -100,7 +100,7 @@ public inline fun <L: List<Boolean>> BooleanArray.filterNotTo(result: L, predica
*
* @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList
*/
public inline fun <L: List<Boolean>> BooleanArray?.filterNotNullTo(result: L) : L {
public inline fun <C: Collection<Boolean>> BooleanArray?.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<Boolean>> BooleanArray.dropWhileTo(result: L, predica
}
/** Returns a list containing the first elements that satisfy the given *predicate* */
public inline fun <L: List<Boolean>> BooleanArray.takeWhileTo(result: L, predicate: (Boolean) -> Boolean) : L {
public inline fun <C: Collection<Boolean>> BooleanArray.takeWhileTo(result: C, predicate: (Boolean) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element) else break
return result
}
@@ -90,7 +90,7 @@ public inline fun <C: Collection<Byte>> ByteArray.filterTo(result: C, predicate:
*
* @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList
*/
public inline fun <L: List<Byte>> ByteArray.filterNotTo(result: L, predicate: (Byte) -> Boolean) : L {
public inline fun <C: Collection<Byte>> ByteArray.filterNotTo(result: C, predicate: (Byte) -> Boolean) : C {
for (element in this) if (!predicate(element)) result.add(element)
return result
}
@@ -100,7 +100,7 @@ public inline fun <L: List<Byte>> ByteArray.filterNotTo(result: L, predicate: (B
*
* @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList
*/
public inline fun <L: List<Byte>> ByteArray?.filterNotNullTo(result: L) : L {
public inline fun <C: Collection<Byte>> ByteArray?.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<Byte>> ByteArray.dropWhileTo(result: L, predicate: (B
}
/** Returns a list containing the first elements that satisfy the given *predicate* */
public inline fun <L: List<Byte>> ByteArray.takeWhileTo(result: L, predicate: (Byte) -> Boolean) : L {
public inline fun <C: Collection<Byte>> ByteArray.takeWhileTo(result: C, predicate: (Byte) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element) else break
return result
}
@@ -90,7 +90,7 @@ public inline fun <C: Collection<Char>> CharArray.filterTo(result: C, predicate:
*
* @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList
*/
public inline fun <L: List<Char>> CharArray.filterNotTo(result: L, predicate: (Char) -> Boolean) : L {
public inline fun <C: Collection<Char>> CharArray.filterNotTo(result: C, predicate: (Char) -> Boolean) : C {
for (element in this) if (!predicate(element)) result.add(element)
return result
}
@@ -100,7 +100,7 @@ public inline fun <L: List<Char>> CharArray.filterNotTo(result: L, predicate: (C
*
* @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList
*/
public inline fun <L: List<Char>> CharArray?.filterNotNullTo(result: L) : L {
public inline fun <C: Collection<Char>> CharArray?.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<Char>> CharArray.dropWhileTo(result: L, predicate: (C
}
/** Returns a list containing the first elements that satisfy the given *predicate* */
public inline fun <L: List<Char>> CharArray.takeWhileTo(result: L, predicate: (Char) -> Boolean) : L {
public inline fun <C: Collection<Char>> CharArray.takeWhileTo(result: C, predicate: (Char) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element) else break
return result
}
@@ -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
}
@@ -90,7 +90,7 @@ public inline fun <C: Collection<Float>> FloatArray.filterTo(result: C, predicat
*
* @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList
*/
public inline fun <L: List<Float>> FloatArray.filterNotTo(result: L, predicate: (Float) -> Boolean) : L {
public inline fun <C: Collection<Float>> FloatArray.filterNotTo(result: C, predicate: (Float) -> Boolean) : C {
for (element in this) if (!predicate(element)) result.add(element)
return result
}
@@ -100,7 +100,7 @@ public inline fun <L: List<Float>> FloatArray.filterNotTo(result: L, predicate:
*
* @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList
*/
public inline fun <L: List<Float>> FloatArray?.filterNotNullTo(result: L) : L {
public inline fun <C: Collection<Float>> FloatArray?.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<Float>> FloatArray.dropWhileTo(result: L, predicate:
}
/** Returns a list containing the first elements that satisfy the given *predicate* */
public inline fun <L: List<Float>> FloatArray.takeWhileTo(result: L, predicate: (Float) -> Boolean) : L {
public inline fun <C: Collection<Float>> FloatArray.takeWhileTo(result: C, predicate: (Float) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element) else break
return result
}
@@ -90,7 +90,7 @@ public inline fun <C: Collection<Int>> IntArray.filterTo(result: C, predicate: (
*
* @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList
*/
public inline fun <L: List<Int>> IntArray.filterNotTo(result: L, predicate: (Int) -> Boolean) : L {
public inline fun <C: Collection<Int>> IntArray.filterNotTo(result: C, predicate: (Int) -> Boolean) : C {
for (element in this) if (!predicate(element)) result.add(element)
return result
}
@@ -100,7 +100,7 @@ public inline fun <L: List<Int>> IntArray.filterNotTo(result: L, predicate: (Int
*
* @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList
*/
public inline fun <L: List<Int>> IntArray?.filterNotNullTo(result: L) : L {
public inline fun <C: Collection<Int>> IntArray?.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<Int>> IntArray.dropWhileTo(result: L, predicate: (Int
}
/** Returns a list containing the first elements that satisfy the given *predicate* */
public inline fun <L: List<Int>> IntArray.takeWhileTo(result: L, predicate: (Int) -> Boolean) : L {
public inline fun <C: Collection<Int>> IntArray.takeWhileTo(result: C, predicate: (Int) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element) else break
return result
}
@@ -88,7 +88,7 @@ public inline fun <T, C: Collection<in T>> java.util.Iterator<T>.filterTo(result
*
* @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList
*/
public inline fun <T, L: List<in T>> java.util.Iterator<T>.filterNotTo(result: L, predicate: (T) -> Boolean) : L {
public inline fun <T, C: Collection<in T>> java.util.Iterator<T>.filterNotTo(result: C, predicate: (T) -> Boolean) : C {
for (element in this) if (!predicate(element)) result.add(element)
return result
}
@@ -98,7 +98,7 @@ public inline fun <T, L: List<in T>> java.util.Iterator<T>.filterNotTo(result: L
*
* @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList
*/
public inline fun <T, L: List<in T>> java.util.Iterator<T?>?.filterNotNullTo(result: L) : L {
public inline fun <T, C: Collection<in T>> java.util.Iterator<T?>?.filterNotNullTo(result: C) : C {
if (this != null) {
for (element in this) if (element != null) result.add(element)
}
@@ -195,7 +195,7 @@ public inline fun <T, L: List<in T>> java.util.Iterator<T>.dropWhileTo(result: L
}
/** Returns a list containing the first elements that satisfy the given *predicate* */
public inline fun <T, L: List<in T>> java.util.Iterator<T>.takeWhileTo(result: L, predicate: (T) -> Boolean) : L {
public inline fun <T, C: Collection<in T>> java.util.Iterator<T>.takeWhileTo(result: C, predicate: (T) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element) else break
return result
}
@@ -90,7 +90,7 @@ public inline fun <C: Collection<Long>> LongArray.filterTo(result: C, predicate:
*
* @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList
*/
public inline fun <L: List<Long>> LongArray.filterNotTo(result: L, predicate: (Long) -> Boolean) : L {
public inline fun <C: Collection<Long>> LongArray.filterNotTo(result: C, predicate: (Long) -> Boolean) : C {
for (element in this) if (!predicate(element)) result.add(element)
return result
}
@@ -100,7 +100,7 @@ public inline fun <L: List<Long>> LongArray.filterNotTo(result: L, predicate: (L
*
* @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList
*/
public inline fun <L: List<Long>> LongArray?.filterNotNullTo(result: L) : L {
public inline fun <C: Collection<Long>> LongArray?.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<Long>> LongArray.dropWhileTo(result: L, predicate: (L
}
/** Returns a list containing the first elements that satisfy the given *predicate* */
public inline fun <L: List<Long>> LongArray.takeWhileTo(result: L, predicate: (Long) -> Boolean) : L {
public inline fun <C: Collection<Long>> LongArray.takeWhileTo(result: C, predicate: (Long) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element) else break
return result
}
@@ -90,7 +90,7 @@ public inline fun <C: Collection<Short>> ShortArray.filterTo(result: C, predicat
*
* @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList
*/
public inline fun <L: List<Short>> ShortArray.filterNotTo(result: L, predicate: (Short) -> Boolean) : L {
public inline fun <C: Collection<Short>> ShortArray.filterNotTo(result: C, predicate: (Short) -> Boolean) : C {
for (element in this) if (!predicate(element)) result.add(element)
return result
}
@@ -100,7 +100,7 @@ public inline fun <L: List<Short>> ShortArray.filterNotTo(result: L, predicate:
*
* @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList
*/
public inline fun <L: List<Short>> ShortArray?.filterNotNullTo(result: L) : L {
public inline fun <C: Collection<Short>> ShortArray?.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<Short>> ShortArray.dropWhileTo(result: L, predicate:
}
/** Returns a list containing the first elements that satisfy the given *predicate* */
public inline fun <L: List<Short>> ShortArray.takeWhileTo(result: L, predicate: (Short) -> Boolean) : L {
public inline fun <C: Collection<Short>> ShortArray.takeWhileTo(result: C, predicate: (Short) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element) else break
return result
}
@@ -90,7 +90,7 @@ public inline fun <T, C: Collection<in T>> Iterable<T>.filterTo(result: C, predi
*
* @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList
*/
public inline fun <T, L: List<in T>> Iterable<T>.filterNotTo(result: L, predicate: (T) -> Boolean) : L {
public inline fun <T, C: Collection<in T>> Iterable<T>.filterNotTo(result: C, predicate: (T) -> Boolean) : C {
for (element in this) if (!predicate(element)) result.add(element)
return result
}
@@ -100,7 +100,7 @@ public inline fun <T, L: List<in T>> Iterable<T>.filterNotTo(result: L, predicat
*
* @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList
*/
public inline fun <T, L: List<in T>> Iterable<T?>?.filterNotNullTo(result: L) : L {
public inline fun <T, C: Collection<in T>> Iterable<T?>?.filterNotNullTo(result: C) : C {
if (this != null) {
for (element in this) if (element != null) result.add(element)
}
@@ -197,7 +197,7 @@ public inline fun <T, L: List<in T>> Iterable<T>.dropWhileTo(result: L, predicat
}
/** Returns a list containing the first elements that satisfy the given *predicate* */
public inline fun <T, L: List<in T>> Iterable<T>.takeWhileTo(result: L, predicate: (T) -> Boolean) : L {
public inline fun <T, C: Collection<in T>> Iterable<T>.takeWhileTo(result: C, predicate: (T) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element) else break
return result
}
@@ -80,7 +80,7 @@ public inline fun <T, C: Collection<in T>> java.lang.Iterable<T>.filterTo(result
*
* @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)
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
*/
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) {
for (element in this) if (element != null) result.add(element)
}
@@ -187,7 +187,7 @@ public inline fun <T, L: List<in T>> java.lang.Iterable<T>.dropWhileTo(result: L
}
/** 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
return result
}