crow/col/set.crow (source)

set[t] record

(has non-public fields)

    Immutable unsorted set.

    new[t] t set(...a t array) t key

    Set containing the given elements (with duplicates removed).

    to[t] t set(a t array) t key

    Set containing the given elements (with duplicates removed).

    to[t] t array(a t set) t key

    Copies set elements to a list.

    is-empty[t] bool(a t set) t key

    true iff a.size == 0.

    size[t] nat64(a t set) t key

    Number of elements in the set.

    in[t] bool(value t, a t set) t key

    true iff value is an element of a.

    subscript[t] bool(a t set, value t) t key

    Alternative way of writing 'value in a'

    ~[t] t set(a t set, value t) t key

    Adds an element to the set.

    If value is alerady in the set, returns a unmodified.

    ~~[t] t set(a t set, b t set) t key

    Same as a | b.

    |[t] t set(a t set, b t set) t key

    Union of two sets.

    This is a set containing all elements in either a or b.

    &[t] t set(a t set, b t set) t key

    Intersection of two sets.

    This is a set containing all elements in both a and b.

    -[t] t set(a t set, b t set) t key

    Set difference.

    This is a set containing all elements in a but not in b.

    try-add[t] t set?(a t set, value t) t key

    If value is already in the set, returns an empty option.
    Else, adds it and returns the new set.

    iterate[t] bool(a t set, f mut bool(t)) t key

    set-builder[t] record mut

    (has non-public fields)

      build[t] t set(a build-options, f mut void(t set-builder)) t key

      ~=[t] void(a t set-builder, value t) t key

      ~~=[t, col] void(a t set-builder, values col) t key, (col, t) iterate