Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > candidate for bitset

Reply
Thread Tools

candidate for bitset

 
 
ma740988
Guest
Posts: n/a
 
      12-14-2005

Given an unsigned int variable that's part of a composite type
struct test {
unsigned int mask;
};

Assume 4 bytes for unsigned int. In one function, I'd like to set
any bit or combination of bits between bits 0 and 23 for the parameter
mask.

So lets suppose I set bits 5, 15 and 23 of mask.

In a separate function I'd like to decode that and store the location
of the bit that was set in a vector .. so in the vector I'd have 5, 15
and 23.

Is this a candidate for bitset? Cant seem to get that to work for me,
then again I'm probably on the wrong track. Trying to determine a way
to make this seemless.

Thanks in advance...

 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      12-14-2005
ma740988 wrote:
> Given an unsigned int variable that's part of a composite type
> struct test {
> unsigned int mask;
> };
>
> Assume 4 bytes for unsigned int. In one function, I'd like to set
> any bit or combination of bits between bits 0 and 23 for the parameter
> mask.
>
> So lets suppose I set bits 5, 15 and 23 of mask.
>
> In a separate function I'd like to decode that and store the location
> of the bit that was set in a vector .. so in the vector I'd have 5, 15
> and 23.
>
> Is this a candidate for bitset? Cant seem to get that to work for me,
> then again I'm probably on the wrong track. Trying to determine a way
> to make this seemless.


Just have fun and implement your own "bitset". What do you think you
can use from std::bitset? 'set' and 'reset'? And std::bitset has no
enumeration, really. So, you'd have to loop over the collection anyway.
Why not challenge your brain to a bit of coding once in a while?

V


 
Reply With Quote
 
 
 
 
ma740988
Guest
Posts: n/a
 
      12-14-2005
Happy holidays Vic.
|| Why not challenge your brain to a bit of
|| coding once in a while?
Ok

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bitset<32> and bitset<64> efficiency Ninds C++ 14 12-03-2012 11:02 PM
Is 'java.util.BitSet' available at JDK1.3? Joshua Java 4 05-06-2005 11:54 AM
Performance of java.util.BitSet Timo Nentwig Java 4 12-11-2003 12:43 AM
Re: bitset to UCHAR Victor Bazarov C++ 1 07-08-2003 09:11 PM
std::bitset construction with std::string question Dill Hole C++ 2 07-04-2003 11:48 PM



Advertisments