in reply to Re^3: Fastest way to test membership in a constant set (Why not?)
in thread Fastest way to test membership in a constant set

Yeah! That cool 'n all, but you're hardly testing like with like. Show me where you code is looking up the words 'age', 'old' and 'years'?

In order to make bitsets practical you have to have a mechanism for mapping the real values (words in this case), with their representative bit patterns. The obvious, and fastest way to do that mapping is to use a hash. And by the time you've done that, you might as well discard the bitset because that hash is doing all the real work, and doing it twice will just be slower.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."
  • Comment on Re^4: Fastest way to test membership in a constant set (Why not?)

Replies are listed 'Best First'.
Re^5: Fastest way to test membership in a constant set (Why not?)
by hipe (Sexton) on Aug 01, 2007 at 13:55 UTC
    Bitsets are often used for representation of sets. That is the reason I was curious to see how they compare with hashes.

    I agree with you that for this and probably most of the cases, hash is a better representation for a set. In case of a lottery, for example, bitsets might be better.