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

macosArm64Main.maryk.rocksdb.AbstractSlice.kt Maven / Gradle / Ivy

package maryk.rocksdb

import rocksdb.RocksDBSlice

actual abstract class AbstractSlice protected constructor(
    val native: RocksDBSlice
) : RocksMutableObject() {

    actual fun data(): T {
        return this.getData()
    }

    protected abstract fun getData(): T

    actual abstract fun removePrefix(n: Int)

    actual abstract fun clear()

    actual fun size(): Int {
        return native.size().toInt()
    }

    actual fun empty(): Boolean {
        return native.empty()
    }

    actual fun toString(hex: Boolean): String {
        return native.toString(hex)!!
    }

    actual override fun toString(): String {
        return native.toString(false)!!
    }

    actual fun compare(other: AbstractSlice<*>): Int {
        return native.compare(other.native)
    }

    actual override fun hashCode(): Int {
        return toString().hashCode()
    }

    actual override fun equals(other: Any?) = when (other) {
        null, !is AbstractSlice<*> -> false
        else -> {
            native.compare(other.native) == 0
        }
    }

    actual fun startsWith(prefix: AbstractSlice<*>): Boolean {
        return native.startsWith(prefix.native)
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy