Remove "Iterator.iterator()" intrinsic, add stdlib function

This commit is contained in:
Alexander Udalov
2014-02-21 21:20:35 +04:00
parent 4a5823c5bb
commit 11cc7f46f4
11 changed files with 29 additions and 99 deletions
@@ -186,17 +186,7 @@ public final class MiscTest extends AbstractExpressionTest {
fooBoxTest();
}
public void testIterableExtension() throws Exception {
fooBoxTest();
}
public void testIterationOverIterator() throws Exception {
fooBoxTest();
}
public void testStringInterpolationEvaluationOrder() throws Exception {
fooBoxTest();
}
}
@@ -1,21 +0,0 @@
package foo
import java.util.*
import java.lang.*
public inline fun <T, C: MutableCollection<in T>> Iterator<T>.takeWhileTo(result: C, predicate: (T) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element) else break
return result
}
fun box(): Any? {
val c = ArrayList<Int>()
for (i in 0..5) {
c.add(i)
}
val d = ArrayList<Int>()
c.iterator().takeWhileTo(d, {i -> i < 4 })
return d.size() == 4
}
@@ -1,18 +0,0 @@
package foo
import java.util.*
fun box(): Boolean {
val c = ArrayList<Int>()
for (i in 0..5) {
c.add(i)
}
var s = ""
for (i in c.iterator()) {
s = s + i.toString()
}
return s == "012345"
}