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

fn newStack() → Stack<T>
fn newQueue() → Queue<T>
fn newPair(first: T, second: U) → Pair<T, U>

class Pair<T, U>

* A pair of two values of potentially different types.

Fields

firstT
secondU

Methods

fn new(first: T, second: U) → Pair<T, U>
fn getFirst() → T
fn getSecond() → U

class Queue<T>

* A First-In-First-Out (FIFO) queue of elements of type T.

Fields

dataList<T>

Methods

fn new() → Queue<T>
fn enqueue(value: T) → Nothing
fn dequeue() → T
fn peek() → T
fn isEmpty() → Bool
fn size() → Int64

class Stack<T>

* A Last-In-First-Out (LIFO) stack of elements of type T.

Fields

dataList<T>

Methods

fn new() → Stack<T>
fn push(value: T) → Nothing
fn pop() → T
fn peek() → T
fn isEmpty() → Bool
fn size() → Int64