commonMain.io.nacular.doodle.utils.MutableTreeSetJs.kt Maven / Gradle / Ivy
package io.nacular.doodle.utils
import io.nacular.doodle.core.Internal
@Internal
public class MutableTreeSetJs(comparator: Comparator, elements: Collection): TreeSetJs(comparator, elements), MutableSet {
public constructor(comparator: Comparator): this(comparator, emptyList())
override fun iterator(): MutableIterator = BstIterator()
override fun add(element: E): Boolean = super.add(element)
override fun remove(element: E): Boolean = super.remove_(element)
override fun addAll(elements: Collection): Boolean = if (elements.isEmpty()) false else elements.all { add(it) }
override fun removeAll(elements: Collection): Boolean = if (elements.isEmpty()) false else elements.all { remove(it) }
override fun retainAll(elements: Collection): Boolean {
val set = elements.toSet()
var result = false
asSequence().filterNot { it in set }.forEach { result = remove(it) }
return result
}
override fun clear(): Unit = super.clear_()
public companion object {
public operator fun > invoke( ): MutableTreeSetJs = MutableTreeSetJs(Comparator { a, b -> a.compareTo(b) })
public operator fun > invoke(elements: Collection): MutableTreeSetJs = MutableTreeSetJs(Comparator { a, b -> a.compareTo(b) }, elements)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy