I am trying to implement an algorithm within an iOS app that will make use of large bitmasks. Each bitmask can be up to 256 bits (32 bytes) in length. I will need to quickly get/set bits at arbitrary locations within the mask, etc.
Are there any built-in language features of C or Objective-C that makes this kind of thing easy to do, or should I expect to write my own functions for manipulating bits within arbitrary character arrays? It doesn’t seem like it would be too hard to do it myself but if there’s something already available that does this efficiently and cleanly, I’d rather not write my own.
Take a look at CFMutableBitVector, which is designed to handle this kind of problem.