Drop deprecated FunctionalList, FunctionalQueue.
Remove dependency on FunctionalList from tests.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
package to
|
||||
|
||||
import kotlin.concurrent.FunctionalList
|
||||
import kotlin.properties.ObservableProperty
|
||||
|
||||
fun f(l: FunctionalList<Int>) {}
|
||||
fun f(l: ObservableProperty<Int>) {}
|
||||
@@ -1,2 +1,2 @@
|
||||
kotlin.Int
|
||||
kotlin.concurrent.FunctionalList
|
||||
kotlin.properties.ObservableProperty
|
||||
|
||||
+2
-2
@@ -2,6 +2,6 @@
|
||||
|
||||
package g
|
||||
|
||||
import kotlin.concurrent.FunctionalList
|
||||
import kotlin.properties.ObservableProperty
|
||||
|
||||
<selection>fun f(l: FunctionalList<Int>) {}</selection>
|
||||
<selection>fun f(l: ObservableProperty<Int>) {}</selection>
|
||||
@@ -1,4 +1,4 @@
|
||||
fun foo(c: kotlin.support.AbstractIterator<kotlin.concurrent.FunctionalList<Int>>) {
|
||||
fun foo(c: kotlin.support.AbstractIterator<kotlin.properties.ObservableProperty<Int>>) {
|
||||
ba<caret>r(c)
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
import kotlin.concurrent.FunctionalList
|
||||
import kotlin.properties.ObservableProperty
|
||||
import kotlin.support.AbstractIterator
|
||||
|
||||
fun foo(c: kotlin.support.AbstractIterator<kotlin.concurrent.FunctionalList<Int>>) {
|
||||
bar<AbstractIterator<FunctionalList<Int>>>(c)
|
||||
fun foo(c: kotlin.support.AbstractIterator<kotlin.properties.ObservableProperty<Int>>) {
|
||||
bar<AbstractIterator<ObservableProperty<Int>>>(c)
|
||||
}
|
||||
|
||||
fun <T> bar(t: T): T = t
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user