Small nitpick: you're not using the ordering of tag values at all, so
referring to your current tag as "threshold" and talking about
greater-than comparisons in the text is a bit confusing, especially
since you're example code doesn't actually do it. I'd just refer to the
values as "tags" or "cookies" or something similar, and not talk about
their ordering at all, since it doesn't matter. (You need to do a clear
before you start recycling tag values, but that's it).
Interestingly, there's a related ingenious data structure that delivers
O(1) set membership testing, O(1) set insert, true O(1) clear, as well
as O(k) iteration over set elements, where k is the number of elements
in the set (bit vectors etc. take O(n), where n is the size of your
"universe" of possible values). The trade-off is spending even more
memory (twice what you would spend with a tagging scheme). It's a
beautifully simple idea. Description here:
http://research.swtch.com/sparse
-Fabian