Question

I have two instances of CFMutableBitVector, like so:

 CFBitVectorRef ref1, ref2;

How can I do bit-wise operations to these guys? For right now, I only care about and, but obviously xor, or, etc would be useful to know.

Obviously I can iterate through the bits in the vector, but that seems silly when I'm working at the bit level. I feel like there are just some Core Foundation functions that I'm missing, but I can't find them.

Thanks,

Kurt

Was it helpful?

Solution

Well a

CFBitVectorRef

is a

typedef const struct __CFBitVector *CFBitVectorRef;

which is a

struct __CFBitVector {
    CFRuntimeBase _base;
    CFIndex _count;         /* number of bits */
    CFIndex _capacity;  /* maximum number of bits */
    __CFBitVectorBucket *_buckets;
}; 

Where

/* The bucket type must be unsigned, at least one byte in size, and
   a power of 2 in number of bits; bits are numbered from 0 from left
   to right (bit 0 is the most significant) */

typedef uint8_t __CFBitVectorBucket;

So you can dive in a do byte wise operations which could speed things up. Of course being non-mutable might hinder things a bit :D

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top