set

Generated by tinox doc

Set<T> — a generic, duplicate-free collection backed by a linear-scan List<T>, with add/remove/contains plus the usual set algebra: union, intersection, difference, isSubsetOf.

Set algebra

import tinox.core.set;

class Main
{
    fnc main() -> Int32
    {
        let a: Set<Int64> = Set<Int64>::new();
        Set::add(a, 1);
        Set::add(a, 2);
        Set::add(a, 3);

        let b: Set<Int64> = Set<Int64>::new();
        Set::add(b, 2);
        Set::add(b, 3);
        Set::add(b, 4);

        println("a contains 2: " + Set::contains(a, 2).toString());

        let union: Set<Int64> = Set::union(a, b);
        println("union size: " + Set::size(union).toString());

        let intersection: Set<Int64> = Set::intersection(a, b);
        println("intersection size: " + Set::size(intersection).toString());

        let difference: Set<Int64> = Set::difference(a, b);
        println("a - b size: " + Set::size(difference).toString());

        return 0;
    }
}