All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.soywiz.kmem.ByteArrayUtils.kt Maven / Gradle / Ivy

Go to download

kmem: Fast memory for Kotlin Common (JVM and JS) using Buffers and Typed Arrays

The newest version!
package com.soywiz.kmem

fun ByteArray.contains(other: ByteArray): Boolean = indexOf(other) >= 0

fun ByteArray.indexOf(other: ByteArray): Int {
	val full = this
	for (n in 0 until full.size - other.size) {
		if (other.indices.all { m -> full[n + m] == other[m] }) {
			return n
		}
	}
	return -1
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy