Merge branch 'master' of github.com:JetBrains/kotlin

This commit is contained in:
James Strachan
2012-04-19 09:52:11 +01:00
61 changed files with 468 additions and 202 deletions
+2 -2
View File
@@ -25,7 +25,7 @@ public inline fun <T> java.util.Iterator<T>.iterator() : java.util.Iterator<T> =
Helper to make java.util.Enumeration usable in for
*/
public fun <erased T> java.util.Enumeration<T>.iterator(): Iterator<T> = object: Iterator<T> {
public override val hasNext: Boolean
override val hasNext: Boolean
get() = hasMoreElements()
public override fun next() : T = nextElement().sure()
@@ -114,4 +114,4 @@ public inline fun Throwable.printStackTrace(writer: PrintWriter): Unit {
public inline fun Throwable.printStackTrace(stream: PrintStream): Unit {
val jlt = this as java.lang.Throwable
jlt.printStackTrace(stream)
}
}
@@ -35,15 +35,15 @@ abstract class FunctionalList<T>(public val size: Int) {
return head
}
public override val hasNext: Boolean
override val hasNext: Boolean
get() = !cur.empty
}
class object {
class Empty<T>() : FunctionalList<T>(0) {
public override val head: T
override val head: T
get() = throw java.util.NoSuchElementException()
public override val tail: FunctionalList<T>
override val tail: FunctionalList<T>
get() = throw java.util.NoSuchElementException()
}
+6 -6
View File
@@ -201,7 +201,7 @@ fun Node.nextSiblings() : Iterator<Node> = NextSiblingIterator(this)
class NextSiblingIterator(var node: Node) : AbstractIterator<Node>() {
protected override fun computeNext(): Unit {
override fun computeNext(): Unit {
val next = node.getNextSibling()
if (next != null) {
setNext(next)
@@ -215,7 +215,7 @@ fun Node.previousSiblings() : Iterator<Node> = PreviousSiblingIterator(this)
class PreviousSiblingIterator(var node: Node) : AbstractIterator<Node>() {
protected override fun computeNext(): Unit {
override fun computeNext(): Unit {
val next = node.getPreviousSibling()
if (next != null) {
setNext(next)
@@ -323,7 +323,7 @@ fun NodeList?.toXmlString(xmlDeclaration: Boolean = false): String {
}
class NodeListAsList(val nodeList: NodeList): AbstractList<Node>() {
public override fun get(index: Int): Node {
override fun get(index: Int): Node {
val node = nodeList.item(index)
if (node == null) {
throw IndexOutOfBoundsException("NodeList does not contain a node at index: " + index)
@@ -332,11 +332,11 @@ class NodeListAsList(val nodeList: NodeList): AbstractList<Node>() {
}
}
public override fun size(): Int = nodeList.getLength()
override fun size(): Int = nodeList.getLength()
}
class ElementListAsList(val nodeList: NodeList): AbstractList<Element>() {
public override fun get(index: Int): Element {
override fun get(index: Int): Element {
val node = nodeList.item(index)
if (node is Element) {
return node
@@ -349,7 +349,7 @@ class ElementListAsList(val nodeList: NodeList): AbstractList<Element>() {
}
}
public override fun size(): Int = nodeList.getLength()
override fun size(): Int = nodeList.getLength()
}
+2 -2
View File
@@ -172,7 +172,7 @@ public inline fun <T: Closeable, R> T.use(block: (T)-> R) : R {
/** Returns an [Iterator] of bytes over an input stream */
public fun InputStream.iterator() : ByteIterator =
object: ByteIterator() {
public override val hasNext : Boolean
override val hasNext : Boolean
get() = available() > 0
public override fun nextByte() : Byte = read().toByte()
@@ -238,7 +238,7 @@ class LineIterator(val reader: BufferedReader) : Iterator<String> {
private var nextValue: String? = null
private var done = false
public override val hasNext: Boolean
override val hasNext: Boolean
get() {
if (nextValue == null && !done) {
nextValue = reader.readLine()
@@ -17,7 +17,7 @@ public abstract class AbstractIterator<T>: java.util.Iterator<T> {
private var state: State = State.NotReady
private var next: T? = null
public override fun hasNext(): Boolean {
override fun hasNext(): Boolean {
require(state != State.Failed)
return when (state) {
State.Done -> false
@@ -26,13 +26,13 @@ public abstract class AbstractIterator<T>: java.util.Iterator<T> {
}
}
public override fun next(): T {
override fun next(): T {
if (!hasNext()) throw NoSuchElementException()
state = State.NotReady
return next.sure()
}
public override fun remove() {
override fun remove() {
throw UnsupportedOperationException()
}