stackOf

fun <T> stackOf(vararg items: T): Stack<T>

Creates a new Stack instance wrapping the given values.

The first of the given items will be the top of the stack, and the last of the given items will be the bottom.

Example:

val stack = stackOf(1, 2, 3)

stack.pop() // 1
stack.pop() // 2
stack.pop() // 3

Return

A new Stack instance.

Author

Elizabeth Paige Harper - https://github.com/foxcapades

Since

0.1.0

Parameters

items

Items that will back the newly created stack.


fun <T> stackOf(items: Iterable<T>): Stack<T>

Creates a new Stack instance wrapping the values provided by the given iterable.

The first item provided by the items iterable will be the top of the stack, and the last item provided by the iterable will be the bottom.

Example:

val items = listOf(1, 2, 3)
val stack = stackOf(items)

stack.pop() // 1
stack.pop() // 2
stack.pop() // 3

Return

A new Stack instance.

Author

Elizabeth Paige Harper - https://github.com/foxcapades

Since

0.1.0

Parameters

items

Items that will back the newly created stack.