pods4k
Performance-oriented data structures for Kotlin
A collection of performance-oriented data structures providing performance and efficiency that might appear to be impossible at first glance.
If you find this library useful, please consider giving it
a
on GitHub and sharing it with others.
Installation
Gradle:
repositories {
mavenCentral()
}
dependencies {
implementation("com.danrusu.pods4k:pods4k:<latest_version>")
}
Maven:
<dependency>
<groupId>com.danrusu.pods4k</groupId>
<artifactId>pods4k</artifactId>
<version>latest_version</version>
</dependency>
Alternatively, you can pick & choose individual components of this library.
Immutable Arrays
Immutable Arrays offer a safer, faster, and more efficient alternative to lists while maintaining familiar syntax.
Key Benefits
2 to 8 times faster than lists for most operations.
Over 4X memory reduction in many common scenarios.
Cannot be modified, even with casting.
Prevents accidental mutation attempts at compile time.
Gather elements more efficiently than mutable lists.
Intuitive list-like syntax
val people = immutableArrayOf(dan, jill, bobby)
// Iterate naturally
for (person in people) {
sendMarketingEmailTo(person)
}
// All the usual operations
val employedPeople = people.filter { it.isEmployed() }
val salaries = employedPeople.map { it.salary }
See Immutable Arrays for more specifics along with detailed comparisons against regular arrays, read-only lists, and immutable lists.
Minimum Requirements
- Kotlin 1.9.25
- This library is K2 compatible as it's used in other projects that use Kotlin 2.1 etc.
- JDK 11
- Automated tests are run on JDK LTS releases 11, 17, & 21
Java Compatibility
Some data structures use techniques which are only supported by the Kotlin compiler. While they can be used in a mixed Java & Kotlin codebase to store one of these data structures in a Java-defined collection, referencing these data structures by their class name is only supported within Kotlin files.