Skip to content
volt
GitHub

std::set

A hash set. Elements need hash(this: T&) -> u64 and eq, like map keys.

Source: std/set.volt

Types

struct std::set

<T: type, Allocator: std::mem::allocator = std::mem::default_allocator> struct set

A hash set: each value at most once. ponytail: a map with a byte of unused value per slot; its own table if that byte matters

Field
m: std::map<T, u8, Allocator> = {}

Methods

<T: type, A: std::mem::allocator> attach fn new_in(static this: std::set<T>, allocator: A) -> std::set<T, A>

an empty set that allocates from allocator

<T: type, A: std::mem::allocator> attach fn reserve(this: std::set<T, A>&, n: usize) -> std::mem::mem_error!void

room for n values without growing

<T: type, A: std::mem::allocator> attach fn add(this: std::set<T, A>&, value: T) -> bool

add value; false when it was already there (then value is deleted)

<T: type, A: std::mem::allocator> attach fn contains(this: std::set<T, A>&, value: T) -> bool

whether value is in the set

<T: type, A: std::mem::allocator> attach fn remove(this: std::set<T, A>&, value: T) -> bool

take value out; false when it wasn't there

<T: type, A: std::mem::allocator> attach fn len(this: std::set<T, A>&) -> usize

how many values it holds

<T: type, A: std::mem::allocator> attach fn clear(this: std::set<T, A>&) -> void

delete every value

<T: type, A: std::mem::allocator> attach fn iter(this: std::set<T, A>&) -> std::set_iter<T>

for (x) in s.iter(): each value, as a reference (don't change it: the set is ordered by it)

struct std::set_iter

<T: type> struct set_iter

walks a set's values in no particular order

Field
it: std::map_iter<T, u8>

Methods

<T: type> attach fn next(this: std::set_iter<T>&) -> T*

the next value