Skip to content

stdlib/setView source ↗

set

7 items · generated by scribe fromstdlib/set.fd· synced 2026-11-15

stdlib/set7 items

Contents

HashSet_new

Create an empty set.

Example: var s = HashSet_new(); HashSet_insert(&mut s, “alice”); HashSet_insert(&mut s, “bob”); HashSet_insert(&mut s, “alice”); println(int_to_str(HashSet_len(s))); assert_eq(HashSet_len(s), 2); assert(HashSet_contains(s, “bob”));

pub fn HashSet_new() -> HashMap<str, i64> {

Returns: HashMap<str, i64>

Defined at line 22


HashSet_insert

Insert v into the set. Idempotent: inserting an existing value is a no-op.

Example: var s = HashSet_new(); HashSet_insert(&mut s, “x”); assert(HashSet_contains(s, “x”));

pub fn HashSet_insert(s: & mut HashMap<str, i64>, v: str) -> void {

Parameters:

  • s: & mut HashMap<str
  • v: str

Returns: void

Defined at line 32


HashSet_contains

True when v is a member of the set.

Example: var s = HashSet_new(); HashSet_insert(&mut s, “x”); assert(!HashSet_contains(s, “y”));

pub fn HashSet_contains(s: HashMap<str, i64>, v: str) -> bool {

Parameters:

  • s: HashMap<str
  • v: str

Returns: bool

Defined at line 42


HashSet_remove

Remove v from the set. No-op when absent.

Example: var s = HashSet_new(); HashSet_insert(&mut s, “x”); HashSet_remove(&mut s, “x”); assert(!HashSet_contains(s, “x”)); assert(HashSet_is_empty(s));

pub fn HashSet_remove(s: & mut HashMap<str, i64>, v: str) -> void {

Parameters:

  • s: & mut HashMap<str
  • v: str

Returns: void

Defined at line 54


HashSet_len

Number of elements in the set.

Example: var s = HashSet_new(); assert_eq(HashSet_len(s), 0);

pub fn HashSet_len(s: HashMap<str, i64>) -> i64 {

Parameters:

  • s: HashMap<str

Returns: i64

Defined at line 63


HashSet_is_empty

True when the set is empty.

Example: var s = HashSet_new(); assert(HashSet_is_empty(s));

pub fn HashSet_is_empty(s: HashMap<str, i64>) -> bool {

Parameters:

  • s: HashMap<str

Returns: bool

Defined at line 72


HashSet_clear

Remove all elements, keeping the allocated table.

Example: var s = HashSet_new(); HashSet_insert(&mut s, “a”); HashSet_insert(&mut s, “b”); HashSet_clear(&mut s); assert_eq(HashSet_len(s), 0);

pub fn HashSet_clear(s: & mut HashMap<str, i64>) -> void {

Parameters:

  • s: & mut HashMap<str

Returns: void

Defined at line 84


Generated by scribe, the Fides documentation generator