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 setA 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!voidroom for n values without growing
<T: type, A: std::mem::allocator> attach fn add(this: std::set<T, A>&, value: T) -> booladd 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) -> boolwhether value is in the set
<T: type, A: std::mem::allocator> attach fn remove(this: std::set<T, A>&, value: T) -> booltake value out; false when it wasn't there
<T: type, A: std::mem::allocator> attach fn len(this: std::set<T, A>&) -> usizehow many values it holds
<T: type, A: std::mem::allocator> attach fn clear(this: std::set<T, A>&) -> voiddelete 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_iterwalks 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