crow/col/mut-set.crow (source)

mut-set[t] record mut

(has non-public fields)

    Mutable unordered set.

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

    New set with the given elements (with duplicates removed).

    to[t] t mut-set(a t set) t key

    Copies an immutable set to a mutable set.

    clear[t] void(a t mut-set) t key

    Removes all elements.

    move-to[t] t array(a t mut-set) t key

    Copies elements to a list, and clears the a.

    move-to[t] t set(a t mut-set) t key

    Copies elements to an immuttable set, and clears a.

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

    Adds an element to the set.
    Does nothing if value is already in the set.

    ~~=[t] void(a t mut-set, values t array) t key

    Adds many elements to the set.
    Ignores values already in the set.

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

    true iff value is a value in the set.

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

    If value is already in the set, returns false.
    Else, adds it and returns true.

    remove[t] bool(a t mut-set, value t) t key

    If value is in the set, return false.
    Else, remove it and return true.

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