From a01c63059e571d9070732b3c165c1735196d4fac Mon Sep 17 00:00:00 2001 From: Fedor Isakov Date: Fri, 14 Jun 2024 10:16:44 +0200 Subject: [PATCH] Drop obsolete code --- .../mps/logic/reactor/util/IdHashSet.kt | 78 ------------------- .../mps/logic/reactor/util/Iterables.kt | 42 ---------- 2 files changed, 120 deletions(-) delete mode 100644 reactor/Core/src/jetbrains/mps/logic/reactor/util/IdHashSet.kt delete mode 100644 reactor/Core/src/jetbrains/mps/logic/reactor/util/Iterables.kt diff --git a/reactor/Core/src/jetbrains/mps/logic/reactor/util/IdHashSet.kt b/reactor/Core/src/jetbrains/mps/logic/reactor/util/IdHashSet.kt deleted file mode 100644 index 37b62566..00000000 --- a/reactor/Core/src/jetbrains/mps/logic/reactor/util/IdHashSet.kt +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2014-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package jetbrains.mps.logic.reactor.util - -import com.github.andrewoma.dexx.collection.DerivedKeyHashMap -import com.github.andrewoma.dexx.collection.KeyFunction -import com.github.andrewoma.dexx.collection.internal.base.AbstractSet - -@Deprecated("obsolete, avoid using in new code") -class IdHashSet : AbstractSet { - - companion object { - - val EMPTY_SET = IdHashSet() - - private fun idkey(value: E) = System.identityHashCode(value) - - } - - var storage: DerivedKeyHashMap - - constructor() { - this.storage = emptyStorage() - } - - constructor(storage: DerivedKeyHashMap) { - this.storage = storage - } - - constructor(copyFrom: Iterable) { - this.storage = copyFrom.fold(emptyStorage()) { s, e -> s.put(idkey(e), e) } - } - - override fun add(value: E): IdHashSet = IdHashSet(storage.put(idkey(value), value)) - - override fun contains(value: E): Boolean = storage.containsKey(idkey(value)) - - override fun remove(value: E): IdHashSet = IdHashSet(storage.remove(idkey(value))) - - override fun iterator(): MutableIterator = object: MutableIterator { - - val storageIt = storage.iterator() - - override fun hasNext(): Boolean = storageIt.hasNext() - - override fun next(): E = storageIt.next().component2() - - override fun remove() { - throw UnsupportedOperationException() - } - } - - private fun emptyStorage(): DerivedKeyHashMap { - return DerivedKeyHashMap(object : KeyFunction { - override fun key(value: E): Int = idkey(value) - }) - } - -} - -@Suppress("UNCHECKED_CAST") -fun emptyIdSet(): IdHashSet = IdHashSet.EMPTY_SET as IdHashSet - -fun singletonIdSet(e: E): IdHashSet = emptyIdSet().add(e) \ No newline at end of file diff --git a/reactor/Core/src/jetbrains/mps/logic/reactor/util/Iterables.kt b/reactor/Core/src/jetbrains/mps/logic/reactor/util/Iterables.kt deleted file mode 100644 index 081c8fef..00000000 --- a/reactor/Core/src/jetbrains/mps/logic/reactor/util/Iterables.kt +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2014-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package jetbrains.mps.logic.reactor.util - -import java.util.* - -/** - * @author Fedor Isakov - */ - -class LazyIterable(val origin: List, val map: (S) -> T) : Iterable { - - val mapped = arrayOfNulls(origin.size) - - override fun iterator(): Iterator = object: Iterator { - - var idx: Int = 0 - - override fun hasNext(): Boolean = idx < origin.size - - override fun next(): T { - if (idx < origin.size && mapped[idx] == null) { - mapped[idx] = map(origin[idx]) - } - return if (idx < origin.size) mapped[idx++] as T else throw NoSuchElementException() - } - } -}