collections
Generated by tinox doc
tinox.core.collections, bundled with the compiler and also available as a standalone tinox-central package.
Stack and queue
import tinox.core.collections
class Main
{
fnc main() -> Int32
{
const stack: Stack<Int64> = Stack::new()
stack.push(1)
stack.push(2)
stack.push(3)
println("stack pop: " + stack.pop().toString()) // 3 (LIFO)
const queue: Queue<Int64> = Queue::new()
queue.enqueue(1)
queue.enqueue(2)
queue.enqueue(3)
println("queue dequeue: " + queue.dequeue().toString()) // 1 (FIFO)
const pair: Pair<String, Int64> = Pair::new("age", 30)
println(pair.getFirst() + " = " + pair.getSecond().toString())
return 0
}
}
class Collections
Methods
@Errorclass EmptyCollectionError
* Thrown by `Stack.pop/peek` and `Queue.dequeue/peek` on an empty collection.
Fields
message | String |
@Errorclass IndexError
* Thrown by `Lists::get` when the index is outside the list.
Fields
message | String |
@Errorclass KeyError
* Thrown by `Maps::getOrThrow` when the key is not present.
Fields
message | String |
class Lists<T>
* Checked list access: `list[i]` aborts on a bad index, `Lists::get` throws a typed * `IndexError` the caller can catch or declare.
Methods
class Maps<V>
* Checked map access: strict `map.get` aborts on a missing key, `Maps::getOrThrow` * throws a typed `KeyError` the caller can catch or declare.
Methods
class Pair<T, U>
* A pair of two values of potentially different types.
Fields
first | T | |
second | U |
Methods
class Queue<T>
* A First-In-First-Out (FIFO) queue of elements of type T.
Fields
data | List<T> |
Methods
class Stack<T>
* A Last-In-First-Out (LIFO) stack of elements of type T.
Fields
data | List<T> |