Skip to content
CryoCryo home
Stdlibcollections

hashset

import std::collections::hashset; · source

HashSet<T, A>

type struct HashSet<T, A = GlobalAlloc> {
    map: HashMap<T, (), A>;

    static new() -> HashSet<T>;
    static new_in(alloc: A) -> HashSet<T, A>;
    static with_capacity(capacity: u64) -> HashSet<T>;
    static with_seed(seed: u64) -> HashSet<T>;
    length(&this) -> u64;
    is_empty(&this) -> boolean;
    contains(&this, value: &T) -> boolean
    where T: Hash + Eq;
    insert(mut &this, value: T) -> boolean
    where T: Hash + Eq;
    try_insert(mut &this, value: T) -> Result<boolean, AllocError>
    where T: Hash + Eq;
    remove(mut &this, value: &T) -> boolean
    where T: Hash + Eq;
    clear(mut &this) -> void;
    iter(&this) -> implement Iterator<T>
    where T: Copy;
    iter_ref(&this) -> implement Iterator<T*>;
}

A thin wrapper over HashMap<T, ()> with the same storage, hasher, and growth behaviour, plus friendlier names. insert returns true when the value was newly added; remove returns true when it was present. iter() needs T: Copy; iter_ref() is the borrowing form for owning element types.

Trait implementations

implement<T, A> trait Drop for struct HashSet<T, A>
where T: Drop, A: Allocator

implement<T> trait Default for struct HashSet<T, GlobalAlloc>

implement<T> trait Clone for struct HashSet<T, GlobalAlloc>
where T: Hash + Eq + Clone

implement<T, A> trait Display for struct HashSet<T, A>
where T: Display, A: Allocator   // std::fmt::display

implement<T, A> trait Debug for struct HashSet<T, A>
where T: Debug, A: Allocator   // std::fmt::display