tests changed

val hasNext -> fun hasNext()
This commit is contained in:
Svetlana Isakova
2012-08-14 14:47:04 +04:00
parent f96fe4879a
commit e1281953e7
20 changed files with 42 additions and 48 deletions
@@ -21,7 +21,7 @@ class MyIterable<T> : Iterable<T>
class MyIterator : Iterator<T>
{
override val hasNext: Boolean = false
override fun hasNext(): Boolean = false
override fun next(): T {
throw UnsupportedOperationException()
}
@@ -1,8 +1,7 @@
import java.util.Enumeration
inline fun <T> java.util.Enumeration<T>.iterator() = object: Iterator<T> {
override val hasNext: Boolean
get() = hasMoreElements()
override fun hasNext(): Boolean = hasMoreElements()
override fun next() = nextElement()
}
@@ -1,8 +1,7 @@
import java.util.Enumeration
inline fun <T> java.util.Enumeration<T>.iterator() = object : Iterator<T> {
public override val hasNext: Boolean
get() = hasMoreElements()
public override fun hasNext(): Boolean = hasMoreElements()
public override fun next() = nextElement()
}
@@ -5,11 +5,11 @@
import java.util.*
import jet.Iterator
fun <T> Iterator<T>.foreach(operation: (element: T) -> Unit) : Unit = while(hasNext) operation(next())
fun <T> Iterator<T>.foreach(operation: (element: T) -> Unit) : Unit = while(hasNext()) operation(next())
fun <T> Iterator<T>.foreach(operation: (index: Int, element: T) -> Unit) : Unit {
var k = 0
while(hasNext)
while(hasNext())
operation(k++, next())
}
@@ -6,7 +6,7 @@ import java.util.*
import jet.Iterator
fun <T, U: Collection<in T>> Iterator<T>.to(container: U) : U {
while(hasNext)
while(hasNext())
container.add(next())
return container
}