Structs
- A
FastSet
is a set ofusize
with fast add, remove, contains, and clear operations. Each instance ofFastSet
has some maximal value, and uses heap space proportional to that value. Every operation except cloning, includingclear
, runs in constant time.new
should also run in constant time ifalloc_zeroed
does, which I am assured is true on any modern OS. Based on a neat trick described by Russ Cox at https://research.swtch.com/sparse. - An
OutOfBounds
error occurs whenFastSet::add
orFastSet::remove
is called with a key that is higher than the set’s capacity