Changed extension in parsing test data (jet -> kt)

This commit is contained in:
Evgeny Gerashchenko
2013-09-17 18:05:44 +04:00
parent 2ee3d22ab9
commit e338cda06d
259 changed files with 519 additions and 400 deletions
+33
View File
@@ -0,0 +1,33 @@
class Queue<T> : IPushPop<T> {
private class Item<T>(val data : T, var next : Item<T>)
private var head : Item<T> = null
private var tail : Item<T> = null
override fun push(item : T) {
val i = Item(item)
if (tail == null) {
head = i
tail = head
} else {
tail.next = i
tail = i
}
}
override fun pop() =
if (head == null)
throw UnderflowException()
else {
val result = head.data
head = head.next
if (head == null)
tail = null
result
}
override val isEmpty
get() = head == null
}