Currently I have a solution where I keep track of objects I am interested in by getting their hashcode via Object.GetHashCode
and then storing them in a HashSet<int>
.
However, I have also been learning about bitmasks and bitwise operations and I am quite intrigued by them. Here is a great question that I found close to what I am looking to do. However, I cannot seem to make this work efficiently for hash codes.
There is also this question, but it seems to deal with 5-bit numbers, when hash codes are int
's (32-bits).
I do get the BitArray
solution (from the first referenced question) working, but it is not as fast as my current HashSet approach is. This is due to the sheer number of items in the BitArray
that need to be created to account for all known hash codes (int.MaxValue
).
Is there some a bitmask/bitwise operation I should consider in making this work with a BitArray
? Or have I totally gone off the beaten path here and should simply stick with my HashSet<int>
solution?