
Implements a versatile stack data structure with various initialization methods, allowing element addition, removal, and both destructive and non-destructive iteration.
= K-Stack :source-highlighter: highlightjs :icons: font :lib-version: 0.3.0
image:https://img.shields.io/badge/license-MIT-green[GitHub] image:https://img.shields.io/badge/docs-dokka-brightgreen[link="https://k-libs.github.io/k-stack/dokka/0.2.0/stack/io.klibs.collections/index.html"] image:https://img.shields.io/maven-central/v/io.k-libs/stack[link="https://search.maven.org/artifact/io.k-libs/stack"]
A simple, pure Kotlin stack implementation.
== Import
== Usage
import io.klibs.collections.*
fun main() { // Make a stack from varargs! val stack = stackOf(1, 2, 3)
// Make a stack from a collection! val stack = stackOf(listOf(1, 2, 3))
// Make a stack the boring way! val stack = Stack()
// Make a stack the crazy way! val stack = Stack( initialCapacity = 16, scaleFactor = 1.5F, maxSize = 100 )
// Push stuff onto a stack! stack.push(3) stack.push(2) stack.push(1)
// Pop stuff off of a stack! stack.pop() // 1 stack.pop() // 2 stack.pop() // 3
// Iterate! (destructively) for (item in stack) println("Popped another item off the stack!")
= K-Stack :source-highlighter: highlightjs :icons: font :lib-version: 0.3.0
image:https://img.shields.io/badge/license-MIT-green[GitHub] image:https://img.shields.io/badge/docs-dokka-brightgreen[link="https://k-libs.github.io/k-stack/dokka/0.2.0/stack/io.klibs.collections/index.html"] image:https://img.shields.io/maven-central/v/io.k-libs/stack[link="https://search.maven.org/artifact/io.k-libs/stack"]
A simple, pure Kotlin stack implementation.
== Import
== Usage
import io.klibs.collections.*
fun main() { // Make a stack from varargs! val stack = stackOf(1, 2, 3)
// Make a stack from a collection! val stack = stackOf(listOf(1, 2, 3))
// Make a stack the boring way! val stack = Stack()
// Make a stack the crazy way! val stack = Stack( initialCapacity = 16, scaleFactor = 1.5F, maxSize = 100 )
// Push stuff onto a stack! stack.push(3) stack.push(2) stack.push(1)
// Pop stuff off of a stack! stack.pop() // 1 stack.pop() // 2 stack.pop() // 3
// Iterate! (destructively) for (item in stack) println("Popped another item off the stack!")