pub rec Set[K];
存储唯一键的哈希集合
inner:带有 u8 虚构(dummy)值的后备哈希映射
pub fun init[K](alloc: *allocator.Allocator, hash_fn: fun(ptr) u64, eq_fn: fun(ptr, ptr) bool) Set[K];
创建一个空集合
alloc:用于后备存储的分配器 hash_fn:键的哈希函数 eq_fn:键的相等性函数 ret:一个新的空 Set[K]
pub fun dnit[K](s: *Set[K]) bool;
释放所有后备存储并重置集合
ret:如果内存成功释放则为 true
pub fun is_empty[K](s: Set[K]) bool;
检查集合是否没有条目
ret:如果集合为空则为 true
pub fun length[K](s: Set[K]) usize;
返回集合中的条目数量
ret:条目数量
pub fun insert[K](s: *Set[K], key: K) Result[bool, str];
向集合中添加一个键
key:要插入的键 ret:如果键是新的则为 ok(true),如果已存在则为 ok(false)
pub fun contains[K](s: *Set[K], key: *K) bool;
检查集合是否包含某个键
key:指向要检查的键的指针 ret:如果键存在则为 true
pub fun remove[K](s: *Set[K], key: *K) Result[bool, str];
从集合中移除一个键
key:指向要移除的键的指针 ret:如果已移除则为 ok(true),如果未找到键则为 ok(false)
pub fun clear[K](s: *Set[K]);
移除所有条目但保留已分配的容量