How to bitwise-and CFBitVector

十年热恋 提交于 2019-12-31 06:58:06

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/9846516/how-to-bitwise-and-cfbitvector

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!