set

Hash Set (Set)

Functions

FunctionDescription
set_pages_for
set_newCreate a new set with given capacity (rounded up to power of 2, min 16).
set_hashInternal: hash function for i64.
set_rehashInternal: rehash when load factor > 0.7.
set_addInsert a value into the set.
set_hasCheck if value is in the set.
set_delRemove a value from the set. Returns 1 if found, 0 otherwise.
set_lenNumber of elements.
set_clearRemove all elements.
set_unionUnion: returns new set containing all elements from a and b.
set_intersectIntersection: returns new set of elements in both a and b.
set_diffDifference: returns new set of elements in a but not in b.
set_subsetSubset: returns 1 if all elements of a are in b.
set_eqEquality: same elements in both sets.
set_to_vecConvert set to vec (unordered).

Details

set_pages_for

fn set_pages_for(n: i64) -> i64

set_new

fn set_new(cap: i64) -> &i64

Create a new set with given capacity (rounded up to power of 2, min 16).

set_hash

fn set_hash(val: i64, cap: i64) -> i64

Internal: hash function for i64.

set_rehash

fn set_rehash(s: &i64)

Internal: rehash when load factor > 0.7.

set_add

fn set_add(s: &i64, val: i64)

Insert a value into the set.

set_has

fn set_has(s: &i64, val: i64) -> i64

Check if value is in the set.

set_del

fn set_del(s: &i64, val: i64) -> i64

Remove a value from the set. Returns 1 if found, 0 otherwise.

set_len

fn set_len(s: &i64) -> i64

Number of elements.

set_clear

fn set_clear(s: &i64)

Remove all elements.

set_union

fn set_union(a: &i64, b: &i64) -> &i64

Union: returns new set containing all elements from a and b.

set_intersect

fn set_intersect(a: &i64, b: &i64) -> &i64

Intersection: returns new set of elements in both a and b.

set_diff

fn set_diff(a: &i64, b: &i64) -> &i64

Difference: returns new set of elements in a but not in b.

set_subset

fn set_subset(a: &i64, b: &i64) -> i64

Subset: returns 1 if all elements of a are in b.

set_eq

fn set_eq(a: &i64, b: &i64) -> i64

Equality: same elements in both sets.

set_to_vec

fn set_to_vec(s: &i64) -> &i64

Convert set to vec (unordered).