I have a char[] vector, representing a bitmap, and I want to convert this to an integer vector where the nth bit in the char array corresponds to the nth entry in the integer array.
I can only think of doing it this way: iterate through each byte, and "extract the nth bit" every time. It's simple, but it seems unnecessarily slow.
I can think of a few optimisations where, if I use "<<" and check whether the rest of the byte is 0, I can skip a few entries, but that won't add much as I expect my vector to be dense.
Any thoughts on how to make this more efficient
Thanks
Aucun commentaire:
Enregistrer un commentaire