Skip to content

Set

Module: std.collections.set
Source: std/collections/set.zn

HashSet[T: Hash + Eq]

Separate-chaining hash set, load factor 0.75


Fields:

buckets: List[List[SetEntry[T]]],
_len: usize,
_capacity: usize,

Constructors:

pub fn new() Self;
pub fn with_capacity(cap: usize) Self;

Getters:

pub fn len(*const self) usize;
pub fn capacity(*const self) usize;
pub fn is_empty(*const self) bool;
pub fn contains(*const self, value: *const T) bool;
pub fn get(*const self, value: *const T) Option[*const T];

Mutations:

pub fn insert(*self, value: T) bool;
pub fn remove(*self, value: *const T) bool;
pub fn clear(*self);

Interfaces:

  • core.ops : Drop, Clone (when T: Clone)

SetEntry[T]

Single set entry


Fields:

pub hash: u64,
pub key: T,