J
Jason
hello,
I've been looking into the idea of using a bitset to store a collection of
fields efficiently in a data structure that uses a large number of elements.
My question is what technique is used to extract subsets of the bitset and
use them in normal types? How would i extract bits 3 - 10 inclusive of a
bitset and store them in a char, for example, or how could I go about
treating some bitset elements as a char value or any other atomic data type
for that matter, if that is a better way of wording the question? I know
about the bitwise operators but am not quite sure how to go about achieving
this. Obviously, I am assuming that the STL class bitset really will save
me space and it wont be too slow extracting values rather than using a
structure with bool values, char, long etc as needed, though i am not happy
about how much space that might use.
thanks for any help or advice
I've been looking into the idea of using a bitset to store a collection of
fields efficiently in a data structure that uses a large number of elements.
My question is what technique is used to extract subsets of the bitset and
use them in normal types? How would i extract bits 3 - 10 inclusive of a
bitset and store them in a char, for example, or how could I go about
treating some bitset elements as a char value or any other atomic data type
for that matter, if that is a better way of wording the question? I know
about the bitwise operators but am not quite sure how to go about achieving
this. Obviously, I am assuming that the STL class bitset really will save
me space and it wont be too slow extracting values rather than using a
structure with bool values, char, long etc as needed, though i am not happy
about how much space that might use.
thanks for any help or advice