diff --git a/README.md b/README.md new file mode 100644 index 0000000..ecfa696 --- /dev/null +++ b/README.md @@ -0,0 +1,29 @@ +# Blitz +Kotlin library which mainly focuses on functional programming. + +Features: +- Monads +- Either +- Caching delegated property (similar to lazy) +- A lot of sequence utils +- Streaming IO using kotlinx.io +- ByteVec (alternative to ByteBuf) +- BitVec (similar to bit sets in other languages) +- "Lazy" sequences +- A lot of generative sequence types +- BitField + +## How to get +```kotlin +repositories { + maven { + name = "alex's repo" + url = uri("http://207.180.202.42:8080/libs") + isAllowInsecureProtocol = true + } +} + +dependencies { + implementation("me.alex_s168:blitz:0.1") +} +``` \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 602b4ab..8619a98 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,7 +5,7 @@ plugins { } group = "me.alex_s168" -version = "0.1" +version = "0.2" repositories { mavenCentral() diff --git a/settings.gradle.kts b/settings.gradle.kts index 0fc5bbe..06d9181 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -2,5 +2,5 @@ plugins { id("org.gradle.toolchains.foojay-resolver-convention") version "0.5.0" } -rootProject.name = "kotlin-bits" +rootProject.name = "blitz" diff --git a/src/main/kotlin/blitz/BitField.kt b/src/main/kotlin/blitz/BitField.kt new file mode 100644 index 0000000..5d19af5 --- /dev/null +++ b/src/main/kotlin/blitz/BitField.kt @@ -0,0 +1,33 @@ +package blitz + +import blitz.collections.BitVec +import kotlin.reflect.KProperty + +abstract class BitField { + private var vec = BitVec(1) + + protected class BitDelegate( + private val thi: BitField, + private val pos: Int, + ) { + operator fun getValue(thisRef: Any?, property: KProperty<*>): Boolean = + thi.vec[pos] + + operator fun setValue(thisRef: Any?, property: KProperty<*>, value: Boolean) { + thi.vec[pos] = value + } + } + + protected fun bit(pos: Int): BitDelegate = + BitDelegate(this, pos) + + fun decode(byte: Byte) { + vec = BitVec.from(byteArrayOf(byte)) + } + + fun encode(): Byte = + vec.toBytes()[0] + + override fun toString(): String = + "${this::class.simpleName}(0b${vec.toBytes()[0].toString(2)})" +} \ No newline at end of file