Removed no-stdlib because kotlin implicitly inherits special interface
This commit is contained in:
parent
d0327d0e90
commit
860c54c1a9
@ -42,11 +42,11 @@ xomrk {
|
||||
compileTaskProvider.configure {
|
||||
compilerOptions {
|
||||
jvmTarget = JvmTarget.JVM_1_8
|
||||
freeCompilerArgs.addAll(
|
||||
"-Xno-call-assertions",
|
||||
"-Xno-param-assertions",
|
||||
"-Xno-receiver-assertions"
|
||||
)
|
||||
// freeCompilerArgs.addAll(
|
||||
// "-Xno-call-assertions",
|
||||
// "-Xno-param-assertions",
|
||||
// "-Xno-receiver-assertions"
|
||||
// )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,9 +2,11 @@ package ru.landgrafhomyak.utility.enumerated_collection
|
||||
|
||||
import kotlin.jvm.JvmStatic
|
||||
|
||||
internal abstract class EnumeratedCollection<E : Any>(
|
||||
private val _data: Array<out E>,
|
||||
public abstract class EnumeratedCollection<E : Any>(
|
||||
data: Array<out E>,
|
||||
) : List<E> {
|
||||
private val _data: Array<out E> = data
|
||||
|
||||
protected abstract fun _getElementOrdinal(e: E): Int
|
||||
abstract override fun toString(): String
|
||||
|
||||
@ -12,8 +14,6 @@ internal abstract class EnumeratedCollection<E : Any>(
|
||||
get() = this._data.size
|
||||
|
||||
override operator fun contains(element: E): Boolean {
|
||||
_Platform.jvm_assertNotNull(element, "param: element")
|
||||
|
||||
val ordinal = this._getElementOrdinal(element)
|
||||
if (ordinal >= this.size)
|
||||
return false
|
||||
@ -23,16 +23,12 @@ internal abstract class EnumeratedCollection<E : Any>(
|
||||
}
|
||||
|
||||
override fun containsAll(elements: Collection<E>): Boolean {
|
||||
_Platform.jvm_assertNotNull(elements, "param: elements")
|
||||
|
||||
if (elements === this) return true
|
||||
return elements.all(this::contains)
|
||||
}
|
||||
|
||||
override fun isEmpty(): Boolean = this._data.isEmpty()
|
||||
|
||||
fun isNotEmpty(): Boolean = this._data.isNotEmpty()
|
||||
|
||||
override operator fun iterator(): Iterator<E> = this._data.iterator()
|
||||
|
||||
override operator fun get(ordinal: Int): E {
|
||||
@ -44,8 +40,6 @@ internal abstract class EnumeratedCollection<E : Any>(
|
||||
}
|
||||
|
||||
override fun indexOf(element: E): Int {
|
||||
_Platform.jvm_assertNotNull(element, "param: element")
|
||||
|
||||
@Suppress("LiftReturnOrAssignment")
|
||||
if (element in this)
|
||||
return this._getElementOrdinal(element)
|
||||
@ -69,10 +63,10 @@ internal abstract class EnumeratedCollection<E : Any>(
|
||||
override fun _getElementOrdinal(e: Any): Int = throw IllegalArgumentException("This method unexpected to be invoked")
|
||||
}
|
||||
|
||||
companion object {
|
||||
public companion object {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
@JvmStatic
|
||||
fun <T : Any> empty(): EnumeratedCollection<T> = Empty as EnumeratedCollection<T>
|
||||
public fun <T : Any> empty(): EnumeratedCollection<T> = Empty as EnumeratedCollection<T>
|
||||
}
|
||||
|
||||
private inner class ListIteratorImpl(private var nextPos: Int) : ListIterator<E> {
|
||||
@ -110,7 +104,6 @@ internal abstract class EnumeratedCollection<E : Any>(
|
||||
override fun isEmpty(): Boolean = this.size != 0
|
||||
|
||||
override fun contains(element: E): Boolean {
|
||||
_Platform.jvm_assertNotNull(element, "param: element")
|
||||
if (element !in this@EnumeratedCollection) return false
|
||||
return this@EnumeratedCollection._getElementOrdinal(element) in (this._start..<this._end)
|
||||
}
|
||||
@ -118,7 +111,6 @@ internal abstract class EnumeratedCollection<E : Any>(
|
||||
override fun iterator(): Iterator<E> = this.listIterator()
|
||||
|
||||
override fun containsAll(elements: Collection<E>): Boolean {
|
||||
_Platform.jvm_assertNotNull(elements, "param: elements")
|
||||
if (elements === this) return true
|
||||
return elements.all(this::contains)
|
||||
}
|
||||
@ -126,7 +118,6 @@ internal abstract class EnumeratedCollection<E : Any>(
|
||||
override fun get(index: Int): E = this@EnumeratedCollection[this._start + index]
|
||||
|
||||
override fun indexOf(element: E): Int {
|
||||
_Platform.jvm_assertNotNull(element, "param: element")
|
||||
if (element !in this) return -1
|
||||
return this@EnumeratedCollection._getElementOrdinal(element) - this._start
|
||||
}
|
||||
|
||||
@ -1,7 +0,0 @@
|
||||
package ru.landgrafhomyak.utility.enumerated_collection
|
||||
|
||||
@PublishedApi
|
||||
internal expect object _Platform {
|
||||
@PublishedApi
|
||||
internal inline fun jvm_assertNotNull(x: Any?, name: String)
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
package ru.landgrafhomyak.utility.enumerated_collection
|
||||
|
||||
import java.util.Objects
|
||||
import kotlin.contracts.contract
|
||||
|
||||
@PublishedApi
|
||||
internal actual object _Platform {
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
@JvmStatic
|
||||
@PublishedApi
|
||||
internal actual inline fun jvm_assertNotNull(x: Any?, name: String) {
|
||||
contract {
|
||||
returns().implies(x != null)
|
||||
}
|
||||
Objects.requireNonNull(x, name)
|
||||
}
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
package ru.landgrafhomyak.utility.enumerated_collection
|
||||
|
||||
|
||||
@PublishedApi
|
||||
internal actual object _Platform {
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
@PublishedApi
|
||||
internal actual inline fun jvm_assertNotNull(x: Any?, name: String) {
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user