0

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

Stuart
  • 36,683
  • 19
  • 101
  • 139
Kurt Spindler
  • 1,311
  • 1
  • 14
  • 22

1 Answers1

0

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

Peter M
  • 7,309
  • 3
  • 50
  • 91
  • 5
    The underlying representation of CFBitVector is an implementation detail, and is therefore subject to change without warning. It should not be relied on in shipping software. – bdash Jan 26 '13 at 07:35
  • @bdash Yes this is implementation dependent. However it is predictable and the assumptions it is using can be tested. In addition I don't see the implementation changing in the near future without significant changes in a lot of software. – Peter M Jan 26 '13 at 21:43