Drop deprecated FunctionalList, FunctionalQueue.

Remove dependency on FunctionalList from tests.
This commit is contained in:
Ilya Gorbunov
2015-07-08 20:32:37 +03:00
parent 0a320a13e5
commit 4de5dd9aeb
8 changed files with 9 additions and 113 deletions
@@ -1,57 +0,0 @@
package kotlin.concurrent
deprecated("This class is unfinished work. It will be removed from the standard library and replaced by a separate persistent collections library")
public abstract class FunctionalList<T>(public val size: Int) {
public abstract val head: T
public abstract val tail: FunctionalList<T>
public val empty: Boolean
get() = size == 0
public fun add(element: T): FunctionalList<T> = FunctionalList.Standard(element, this)
public fun reversed(): FunctionalList<T> {
if(empty)
return this
var cur = tail
var new = of(head)
while(!cur.empty) {
new = new.add(cur.head)
cur = cur.tail
}
return new
}
public fun iterator() : Iterator<T> = object: Iterator<T> {
var cur = this@FunctionalList
public override fun next(): T {
if(cur.empty)
throw java.util.NoSuchElementException()
val head = cur.head
cur = cur.tail
return head
}
override fun hasNext(): Boolean = !cur.empty
}
private class Empty<T>() : FunctionalList<T>(0) {
override val head: T
get() = throw java.util.NoSuchElementException()
override val tail: FunctionalList<T>
get() = throw java.util.NoSuchElementException()
}
private class Standard<T>(override val head: T, override val tail: FunctionalList<T>) : FunctionalList<T>(tail.size + 1)
companion object {
public fun <T> emptyList(): FunctionalList<T> = Empty<T>()
public fun <T> of(element: T): FunctionalList<T> = FunctionalList.Standard<T>(element, emptyList())
}
}
@@ -1,31 +0,0 @@
package kotlin.concurrent
import java.util.concurrent.Executor
deprecated("This class is unfinished work. It will be removed from the standard library and replaced by a separate persistent collections library")
public class FunctionalQueue<T> (
private val input: FunctionalList<T> = FunctionalList.emptyList<T>(),
private val output: FunctionalList<T> = FunctionalList.emptyList<T>()
) {
public val size: Int
get() = input.size + output.size
public val empty: Boolean
get() = size == 0
public fun add(element: T): FunctionalQueue<T> = FunctionalQueue<T>(input add element, output)
public fun addFirst(element: T): FunctionalQueue<T> = FunctionalQueue<T>(input, output add element)
public fun removeFirst(): Pair<T, FunctionalQueue<T>> =
if (output.empty) {
if (input.empty)
throw java.util.NoSuchElementException()
else
FunctionalQueue<T>(FunctionalList.emptyList<T>(), input.reversed()).removeFirst()
}
else {
Pair(output.head, FunctionalQueue<T>(input, output.tail))
}
}
@@ -1,16 +0,0 @@
package test.concurrent
import kotlin.concurrent.*
import junit.framework.*
class FListTest() : TestCase() {
fun testEmpty() {
val empty = FunctionalQueue<Int> ()
Assert.assertTrue(empty.empty)
}
fun testNonEmpty() {
// val empty = FunctionalList.emptyList<Int> ()
// assertTrue(!(empty + 10).empty)
}
}