Implement asList, slice & sliceArray extension functions for UArrays
This commit is contained in:
committed by
Ilya Gorbunov
parent
114736c09b
commit
fc85781bfc
@@ -46,8 +46,7 @@ internal constructor(@PublishedApi internal val storage: ByteArray) : Collection
|
||||
}
|
||||
|
||||
override fun containsAll(elements: Collection<UByte>): Boolean {
|
||||
if ((elements as Collection<Any?>).any { it as? UByte == null }) return false
|
||||
return elements.all { storage.contains(it.toByte()) }
|
||||
return (elements as Collection<*>).all { it is UByte && storage.contains(it.toByte()) }
|
||||
}
|
||||
|
||||
override fun isEmpty(): Boolean = this.storage.size == 0
|
||||
|
||||
@@ -46,8 +46,7 @@ internal constructor(@PublishedApi internal val storage: IntArray) : Collection<
|
||||
}
|
||||
|
||||
override fun containsAll(elements: Collection<UInt>): Boolean {
|
||||
if ((elements as Collection<Any?>).any { it as? UInt == null }) return false
|
||||
return elements.all { storage.contains(it.toInt()) }
|
||||
return (elements as Collection<*>).all { it is UInt && storage.contains(it.toInt()) }
|
||||
}
|
||||
|
||||
override fun isEmpty(): Boolean = this.storage.size == 0
|
||||
|
||||
@@ -46,8 +46,7 @@ internal constructor(@PublishedApi internal val storage: LongArray) : Collection
|
||||
}
|
||||
|
||||
override fun containsAll(elements: Collection<ULong>): Boolean {
|
||||
if ((elements as Collection<Any?>).any { it as? ULong == null }) return false
|
||||
return elements.all { storage.contains(it.toLong()) }
|
||||
return (elements as Collection<*>).all { it is ULong && storage.contains(it.toLong()) }
|
||||
}
|
||||
|
||||
override fun isEmpty(): Boolean = this.storage.size == 0
|
||||
|
||||
@@ -46,8 +46,7 @@ internal constructor(@PublishedApi internal val storage: ShortArray) : Collectio
|
||||
}
|
||||
|
||||
override fun containsAll(elements: Collection<UShort>): Boolean {
|
||||
if ((elements as Collection<Any?>).any { it as? UShort == null }) return false
|
||||
return elements.all { storage.contains(it.toShort()) }
|
||||
return (elements as Collection<*>).all { it is UShort && storage.contains(it.toShort()) }
|
||||
}
|
||||
|
||||
override fun isEmpty(): Boolean = this.storage.size == 0
|
||||
|
||||
Reference in New Issue
Block a user