create Collections.kt

This commit is contained in:
tursom 2020-08-23 02:34:51 +08:00
parent c01916332c
commit bcc5301635
3 changed files with 347 additions and 7 deletions

View File

@ -0,0 +1,342 @@
package cn.tursom.core
operator fun <T> Map<in Int, T>.component1() = this[0]
operator fun <T> Map<in Int, T>.component2() = this[1]
operator fun <T> Map<in Int, T>.component3() = this[2]
operator fun <T> Map<in Int, T>.component4() = this[3]
operator fun <T> Map<in Int, T>.component5() = this[4]
operator fun <T> Map<in Int, T>.component6() = this[5]
operator fun <T> Map<in Int, T>.component7() = this[6]
operator fun <T> Map<in Int, T>.component8() = this[7]
operator fun <T> Map<in Int, T>.component9() = this[8]
operator fun <T> Map<in Int, T>.component10() = this[9]
operator fun <T> Map<in Int, T>.component11() = this[10]
operator fun <T> Map<in Int, T>.component12() = this[11]
operator fun <T> Map<in Int, T>.component13() = this[12]
operator fun <T> Map<in Int, T>.component14() = this[13]
operator fun <T> Map<in Int, T>.component15() = this[14]
operator fun <T> Map<in Int, T>.component16() = this[15]
operator fun <T> Map<in Int, T>.component17() = this[16]
operator fun <T> Map<in Int, T>.component18() = this[17]
operator fun <T> Map<in Int, T>.component19() = this[18]
operator fun <T> Map<in Int, T>.component20() = this[19]
operator fun <T> Map<in Int, T>.component21() = this[20]
operator fun <T> Map<in Int, T>.component22() = this[21]
operator fun <T> Map<in Int, T>.component23() = this[22]
operator fun <T> Map<in Int, T>.component24() = this[23]
operator fun <T> Map<in Int, T>.component25() = this[24]
operator fun <T> Map<in Int, T>.component26() = this[25]
operator fun <T> Map<in Int, T>.component27() = this[26]
operator fun <T> Map<in Int, T>.component28() = this[27]
operator fun <T> Map<in Int, T>.component29() = this[28]
operator fun <T> Map<in Int, T>.component30() = this[29]
operator fun <T> List<T>.component1() = this[0]
operator fun <T> List<T>.component2() = this[1]
operator fun <T> List<T>.component3() = this[2]
operator fun <T> List<T>.component4() = this[3]
operator fun <T> List<T>.component5() = this[4]
operator fun <T> List<T>.component6() = this[5]
operator fun <T> List<T>.component7() = this[6]
operator fun <T> List<T>.component8() = this[7]
operator fun <T> List<T>.component9() = this[8]
operator fun <T> List<T>.component10() = this[9]
operator fun <T> List<T>.component11() = this[10]
operator fun <T> List<T>.component12() = this[11]
operator fun <T> List<T>.component13() = this[12]
operator fun <T> List<T>.component14() = this[13]
operator fun <T> List<T>.component15() = this[14]
operator fun <T> List<T>.component16() = this[15]
operator fun <T> List<T>.component17() = this[16]
operator fun <T> List<T>.component18() = this[17]
operator fun <T> List<T>.component19() = this[18]
operator fun <T> List<T>.component20() = this[19]
operator fun <T> List<T>.component21() = this[20]
operator fun <T> List<T>.component22() = this[21]
operator fun <T> List<T>.component23() = this[22]
operator fun <T> List<T>.component24() = this[23]
operator fun <T> List<T>.component25() = this[24]
operator fun <T> List<T>.component26() = this[25]
operator fun <T> List<T>.component27() = this[26]
operator fun <T> List<T>.component28() = this[27]
operator fun <T> List<T>.component29() = this[28]
operator fun <T> List<T>.component30() = this[29]
operator fun <T> Array<T>.component1() = this[0]
operator fun <T> Array<T>.component2() = this[1]
operator fun <T> Array<T>.component3() = this[2]
operator fun <T> Array<T>.component4() = this[3]
operator fun <T> Array<T>.component5() = this[4]
operator fun <T> Array<T>.component6() = this[5]
operator fun <T> Array<T>.component7() = this[6]
operator fun <T> Array<T>.component8() = this[7]
operator fun <T> Array<T>.component9() = this[8]
operator fun <T> Array<T>.component10() = this[9]
operator fun <T> Array<T>.component11() = this[10]
operator fun <T> Array<T>.component12() = this[11]
operator fun <T> Array<T>.component13() = this[12]
operator fun <T> Array<T>.component14() = this[13]
operator fun <T> Array<T>.component15() = this[14]
operator fun <T> Array<T>.component16() = this[15]
operator fun <T> Array<T>.component17() = this[16]
operator fun <T> Array<T>.component18() = this[17]
operator fun <T> Array<T>.component19() = this[18]
operator fun <T> Array<T>.component20() = this[19]
operator fun <T> Array<T>.component21() = this[20]
operator fun <T> Array<T>.component22() = this[21]
operator fun <T> Array<T>.component23() = this[22]
operator fun <T> Array<T>.component24() = this[23]
operator fun <T> Array<T>.component25() = this[24]
operator fun <T> Array<T>.component26() = this[25]
operator fun <T> Array<T>.component27() = this[26]
operator fun <T> Array<T>.component28() = this[27]
operator fun <T> Array<T>.component29() = this[28]
operator fun <T> Array<T>.component30() = this[29]
operator fun CharArray.component1() = this[0]
operator fun CharArray.component2() = this[1]
operator fun CharArray.component3() = this[2]
operator fun CharArray.component4() = this[3]
operator fun CharArray.component5() = this[4]
operator fun CharArray.component6() = this[5]
operator fun CharArray.component7() = this[6]
operator fun CharArray.component8() = this[7]
operator fun CharArray.component9() = this[8]
operator fun CharArray.component10() = this[9]
operator fun CharArray.component11() = this[10]
operator fun CharArray.component12() = this[11]
operator fun CharArray.component13() = this[12]
operator fun CharArray.component14() = this[13]
operator fun CharArray.component15() = this[14]
operator fun CharArray.component16() = this[15]
operator fun CharArray.component17() = this[16]
operator fun CharArray.component18() = this[17]
operator fun CharArray.component19() = this[18]
operator fun CharArray.component20() = this[19]
operator fun CharArray.component21() = this[20]
operator fun CharArray.component22() = this[21]
operator fun CharArray.component23() = this[22]
operator fun CharArray.component24() = this[23]
operator fun CharArray.component25() = this[24]
operator fun CharArray.component26() = this[25]
operator fun CharArray.component27() = this[26]
operator fun CharArray.component28() = this[27]
operator fun CharArray.component29() = this[28]
operator fun CharArray.component30() = this[29]
operator fun ByteArray.component1() = this[0]
operator fun ByteArray.component2() = this[1]
operator fun ByteArray.component3() = this[2]
operator fun ByteArray.component4() = this[3]
operator fun ByteArray.component5() = this[4]
operator fun ByteArray.component6() = this[5]
operator fun ByteArray.component7() = this[6]
operator fun ByteArray.component8() = this[7]
operator fun ByteArray.component9() = this[8]
operator fun ByteArray.component10() = this[9]
operator fun ByteArray.component11() = this[10]
operator fun ByteArray.component12() = this[11]
operator fun ByteArray.component13() = this[12]
operator fun ByteArray.component14() = this[13]
operator fun ByteArray.component15() = this[14]
operator fun ByteArray.component16() = this[15]
operator fun ByteArray.component17() = this[16]
operator fun ByteArray.component18() = this[17]
operator fun ByteArray.component19() = this[18]
operator fun ByteArray.component20() = this[19]
operator fun ByteArray.component21() = this[20]
operator fun ByteArray.component22() = this[21]
operator fun ByteArray.component23() = this[22]
operator fun ByteArray.component24() = this[23]
operator fun ByteArray.component25() = this[24]
operator fun ByteArray.component26() = this[25]
operator fun ByteArray.component27() = this[26]
operator fun ByteArray.component28() = this[27]
operator fun ByteArray.component29() = this[28]
operator fun ByteArray.component30() = this[29]
operator fun ShortArray.component1() = this[0]
operator fun ShortArray.component2() = this[1]
operator fun ShortArray.component3() = this[2]
operator fun ShortArray.component4() = this[3]
operator fun ShortArray.component5() = this[4]
operator fun ShortArray.component6() = this[5]
operator fun ShortArray.component7() = this[6]
operator fun ShortArray.component8() = this[7]
operator fun ShortArray.component9() = this[8]
operator fun ShortArray.component10() = this[9]
operator fun ShortArray.component11() = this[10]
operator fun ShortArray.component12() = this[11]
operator fun ShortArray.component13() = this[12]
operator fun ShortArray.component14() = this[13]
operator fun ShortArray.component15() = this[14]
operator fun ShortArray.component16() = this[15]
operator fun ShortArray.component17() = this[16]
operator fun ShortArray.component18() = this[17]
operator fun ShortArray.component19() = this[18]
operator fun ShortArray.component20() = this[19]
operator fun ShortArray.component21() = this[20]
operator fun ShortArray.component22() = this[21]
operator fun ShortArray.component23() = this[22]
operator fun ShortArray.component24() = this[23]
operator fun ShortArray.component25() = this[24]
operator fun ShortArray.component26() = this[25]
operator fun ShortArray.component27() = this[26]
operator fun ShortArray.component28() = this[27]
operator fun ShortArray.component29() = this[28]
operator fun ShortArray.component30() = this[29]
operator fun IntArray.component1() = this[0]
operator fun IntArray.component2() = this[1]
operator fun IntArray.component3() = this[2]
operator fun IntArray.component4() = this[3]
operator fun IntArray.component5() = this[4]
operator fun IntArray.component6() = this[5]
operator fun IntArray.component7() = this[6]
operator fun IntArray.component8() = this[7]
operator fun IntArray.component9() = this[8]
operator fun IntArray.component10() = this[9]
operator fun IntArray.component11() = this[10]
operator fun IntArray.component12() = this[11]
operator fun IntArray.component13() = this[12]
operator fun IntArray.component14() = this[13]
operator fun IntArray.component15() = this[14]
operator fun IntArray.component16() = this[15]
operator fun IntArray.component17() = this[16]
operator fun IntArray.component18() = this[17]
operator fun IntArray.component19() = this[18]
operator fun IntArray.component20() = this[19]
operator fun IntArray.component21() = this[20]
operator fun IntArray.component22() = this[21]
operator fun IntArray.component23() = this[22]
operator fun IntArray.component24() = this[23]
operator fun IntArray.component25() = this[24]
operator fun IntArray.component26() = this[25]
operator fun IntArray.component27() = this[26]
operator fun IntArray.component28() = this[27]
operator fun IntArray.component29() = this[28]
operator fun IntArray.component30() = this[29]
operator fun LongArray.component1() = this[0]
operator fun LongArray.component2() = this[1]
operator fun LongArray.component3() = this[2]
operator fun LongArray.component4() = this[3]
operator fun LongArray.component5() = this[4]
operator fun LongArray.component6() = this[5]
operator fun LongArray.component7() = this[6]
operator fun LongArray.component8() = this[7]
operator fun LongArray.component9() = this[8]
operator fun LongArray.component10() = this[9]
operator fun LongArray.component11() = this[10]
operator fun LongArray.component12() = this[11]
operator fun LongArray.component13() = this[12]
operator fun LongArray.component14() = this[13]
operator fun LongArray.component15() = this[14]
operator fun LongArray.component16() = this[15]
operator fun LongArray.component17() = this[16]
operator fun LongArray.component18() = this[17]
operator fun LongArray.component19() = this[18]
operator fun LongArray.component20() = this[19]
operator fun LongArray.component21() = this[20]
operator fun LongArray.component22() = this[21]
operator fun LongArray.component23() = this[22]
operator fun LongArray.component24() = this[23]
operator fun LongArray.component25() = this[24]
operator fun LongArray.component26() = this[25]
operator fun LongArray.component27() = this[26]
operator fun LongArray.component28() = this[27]
operator fun LongArray.component29() = this[28]
operator fun LongArray.component30() = this[29]
operator fun FloatArray.component1() = this[0]
operator fun FloatArray.component2() = this[1]
operator fun FloatArray.component3() = this[2]
operator fun FloatArray.component4() = this[3]
operator fun FloatArray.component5() = this[4]
operator fun FloatArray.component6() = this[5]
operator fun FloatArray.component7() = this[6]
operator fun FloatArray.component8() = this[7]
operator fun FloatArray.component9() = this[8]
operator fun FloatArray.component10() = this[9]
operator fun FloatArray.component11() = this[10]
operator fun FloatArray.component12() = this[11]
operator fun FloatArray.component13() = this[12]
operator fun FloatArray.component14() = this[13]
operator fun FloatArray.component15() = this[14]
operator fun FloatArray.component16() = this[15]
operator fun FloatArray.component17() = this[16]
operator fun FloatArray.component18() = this[17]
operator fun FloatArray.component19() = this[18]
operator fun FloatArray.component20() = this[19]
operator fun FloatArray.component21() = this[20]
operator fun FloatArray.component22() = this[21]
operator fun FloatArray.component23() = this[22]
operator fun FloatArray.component24() = this[23]
operator fun FloatArray.component25() = this[24]
operator fun FloatArray.component26() = this[25]
operator fun FloatArray.component27() = this[26]
operator fun FloatArray.component28() = this[27]
operator fun FloatArray.component29() = this[28]
operator fun FloatArray.component30() = this[29]
operator fun DoubleArray.component1() = this[0]
operator fun DoubleArray.component2() = this[1]
operator fun DoubleArray.component3() = this[2]
operator fun DoubleArray.component4() = this[3]
operator fun DoubleArray.component5() = this[4]
operator fun DoubleArray.component6() = this[5]
operator fun DoubleArray.component7() = this[6]
operator fun DoubleArray.component8() = this[7]
operator fun DoubleArray.component9() = this[8]
operator fun DoubleArray.component10() = this[9]
operator fun DoubleArray.component11() = this[10]
operator fun DoubleArray.component12() = this[11]
operator fun DoubleArray.component13() = this[12]
operator fun DoubleArray.component14() = this[13]
operator fun DoubleArray.component15() = this[14]
operator fun DoubleArray.component16() = this[15]
operator fun DoubleArray.component17() = this[16]
operator fun DoubleArray.component18() = this[17]
operator fun DoubleArray.component19() = this[18]
operator fun DoubleArray.component20() = this[19]
operator fun DoubleArray.component21() = this[20]
operator fun DoubleArray.component22() = this[21]
operator fun DoubleArray.component23() = this[22]
operator fun DoubleArray.component24() = this[23]
operator fun DoubleArray.component25() = this[24]
operator fun DoubleArray.component26() = this[25]
operator fun DoubleArray.component27() = this[26]
operator fun DoubleArray.component28() = this[27]
operator fun DoubleArray.component29() = this[28]
operator fun DoubleArray.component30() = this[29]
operator fun BooleanArray.component1() = this[0]
operator fun BooleanArray.component2() = this[1]
operator fun BooleanArray.component3() = this[2]
operator fun BooleanArray.component4() = this[3]
operator fun BooleanArray.component5() = this[4]
operator fun BooleanArray.component6() = this[5]
operator fun BooleanArray.component7() = this[6]
operator fun BooleanArray.component8() = this[7]
operator fun BooleanArray.component9() = this[8]
operator fun BooleanArray.component10() = this[9]
operator fun BooleanArray.component11() = this[10]
operator fun BooleanArray.component12() = this[11]
operator fun BooleanArray.component13() = this[12]
operator fun BooleanArray.component14() = this[13]
operator fun BooleanArray.component15() = this[14]
operator fun BooleanArray.component16() = this[15]
operator fun BooleanArray.component17() = this[16]
operator fun BooleanArray.component18() = this[17]
operator fun BooleanArray.component19() = this[18]
operator fun BooleanArray.component20() = this[19]
operator fun BooleanArray.component21() = this[20]
operator fun BooleanArray.component22() = this[21]
operator fun BooleanArray.component23() = this[22]
operator fun BooleanArray.component24() = this[23]
operator fun BooleanArray.component25() = this[24]
operator fun BooleanArray.component26() = this[25]
operator fun BooleanArray.component27() = this[26]
operator fun BooleanArray.component28() = this[27]
operator fun BooleanArray.component29() = this[28]
operator fun BooleanArray.component30() = this[29]

View File

@ -321,7 +321,6 @@ fun ByteArray.ungz(): ByteArray {
}
fun ByteArray.undeflate(): ByteArray {
var len = 0
val infl = Inflater()
infl.setInput(this)
val bos = ByteArrayOutputStream()
@ -329,7 +328,7 @@ fun ByteArray.undeflate(): ByteArray {
bos.use {
while (!infl.finished()) {
// 解压缩并将解压缩后的内容输出到字节输出流bos中
len = infl.inflate(outByte)
val len = infl.inflate(outByte)
if (len == 0) {
break
}
@ -342,7 +341,6 @@ fun ByteArray.undeflate(): ByteArray {
fun ByteArray.deflate(): ByteArray {
var len = 0
val defl = Deflater()
defl.setInput(this)
defl.finish()
@ -351,7 +349,7 @@ fun ByteArray.deflate(): ByteArray {
bos.use {
while (!defl.finished()) {
// 压缩并将压缩后的内容输出到字节输出流bos中
len = defl.deflate(outputByte)
val len = defl.deflate(outputByte)
bos.write(outputByte, 0, len)
}
defl.end()

View File

@ -6,7 +6,7 @@ import cn.tursom.core.toUTF8String
import java.io.File
@Suppress("unused", "FunctionName")
@Suppress("unused", "FunctionName", "NAME_SHADOWING")
object MurmurHash3 {
private fun fmix32(h: Int): Int {
var h = h
@ -89,9 +89,9 @@ object MurmurHash3 {
var pos = offset
val end = offset + len
var k1 = 0
var k2 = 0
var k2: Int
var shift = 0
var bits = 0
var bits: Int
var nBytes = 0 // length in UTF8 bytes
while (pos < end) {
val code = data[pos++].toInt()