Skip to content

set

Helpers for HashSet that the standard library does not provide.

The standard library already has the pairwise operations (union, intersection, difference, …); these cover what it lacks: combining any number of sets, toggling a member, a stable order, a similarity score and the power set. Inputs are borrowed and results are new values.

Cargo feature set (enabled by default). To compile only this module:

cargo add helpers4 --no-default-features --features set

or in Cargo.toml:

[dependencies]
helpers4 = { version = "0.0.6", default-features = false, features = ["set"] }

Import path: helpers4::set.

ItemWhat it does
intersection_allThe elements that appear in every set of sets.
jaccardThe Jaccard similarity of two sets: the size of their intersection over the size of their union.
MAX_SUBSET_ITEMSThe most items subsets accepts: 2^16 = 65 536 subsets.
subsetsEvery subset of items (the power set), including the empty one and items itself.
to_sorted_vecThe elements of set as a sorted Vec.
toggleRemoves item from set if it is there, inserts it otherwise.
union_allThe union of every set in sets.