Data.BitSet
A set of the integers 0 .. capacity - 1, one bit each, in 64-bit words.
The capacity is fixed when the set is made, and the set costs a bit for
every integer it could hold whether or not it holds it. That is the right
trade where the elements are dense small indices -- the ids of one
function's values -- and the wrong one for a sparse or unbounded set, which
is what Data.Set is for. An element outside the capacity panics, rounded
up to a whole word: the words are all there is to check against.
Bit n % 64 of word n / 64 holds n, so bit 63 is a word's sign bit.
Nothing here reads a word as a number, only as bits, and the one arithmetic
shift is masked back to six bits.
Returns True if the element was present.
Adds every element of from to into, and says whether that added any.
The two must have the same capacity.
Makes into hold exactly the elements of from, of the same capacity.
Of two sets of the same capacity.
Ascending. Each word is walked by its lowest set bit, so the cost is per element and per word, not per bit.
Counted first so the answer is allocated once at its size: a caller that snapshots a set at every instruction otherwise pays for the array doubling its way up, which cost more allocations than the set itself saved.
Equal when they hold the same elements, whatever their capacities: a word one set has and the other does not must be empty.