473,327 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

A dynamic bitset?

How would be the best solution to create a dynamic bitset cause with
the stl bitset you have to give a number of how big the bitset will be
and i dont know the size at the beginning...

Thanks very much!!

Nov 4 '05 #1
8 8453
to**********@students.fh-vorarlberg.ac.at wrote:
How would be the best solution to create a dynamic bitset cause with
the stl bitset you have to give a number of how big the bitset will be
and i dont know the size at the beginning...

Thanks very much!!


boost::dynamic_bitset
Nov 4 '05 #2
to**********@students.fh-vorarlberg.ac.at wrote:
How would be the best solution to create a dynamic bitset cause with
the stl bitset you have to give a number of how big the bitset will be
and i dont know the size at the beginning...

Thanks very much!!


vector<bool> is a possibility. Depends exactly what you want to do.

john
Nov 4 '05 #3
vector<bool> would be too big for me... But vector<bitset<32> > is a
possibility

Nov 4 '05 #4
to**********@vol.at wrote:
vector<bool> would be too big for me... But vector<bitset<32> > is a
possibility


'std::vector<bool>' is supposed to be specialized as a bit-vector, not as a
plain vector of 'bool' objects, meaning that it will be essentially the same as
your 'vector<bitset<32> >', but with more natural interface. Check your
standard library implementation.

--
Best regards,
Andrey Tarasevich
Nov 4 '05 #5

Andrey Tarasevich schrieb:
to**********@vol.at wrote:
vector<bool> would be too big for me... But vector<bitset<32> > is a
possibility


'std::vector<bool>' is supposed to be specialized as a bit-vector, not as a
plain vector of 'bool' objects, meaning that it will be essentially the same as
your 'vector<bitset<32> >', but with more natural interface. Check your
standard library implementation.

--
Best regards,
Andrey Tarasevich


Really?!? But when i had to write convertations from numbers to bits
and from bits to numbers.... Correct?

Nov 4 '05 #6
to**********@vol.at wrote:
> vector<bool> would be too big for me... But vector<bitset<32> > is a
> possibility
'std::vector<bool>' is supposed to be specialized as a bit-vector, not as a
plain vector of 'bool' objects, meaning that it will be essentially the same as
your 'vector<bitset<32> >', but with more natural interface. Check your
standard library implementation.


Really?!?


Yes.
But when i had to write convertations from numbers to bits
and from bits to numbers.... Correct?


Er... Sorry, but I don't understand the question. Can you please clarify?

--
Best regards,
Andrey Tarasevich
Nov 4 '05 #7
With bitsets you can make things like:

bitset<32> bits(12);
bits = 4;
int var = bits.to_ulong();

So i can create the bits out of a number. With this bitvectors i had to
write such functions...

Nov 4 '05 #8
to**********@vol.at wrote:
With bitsets you can make things like:

bitset<32> bits(12);
bits = 4;
int var = bits.to_ulong();

So i can create the bits out of a number. With this bitvectors i had to
write such functions...


Yes, with 'std::vector<bool>' you'll have to write it yourself or use a
third-party implementation.

--
Best regards,
Andrey Tarasevich
Nov 4 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Hunter Hou | last post by:
Hello, I have this very simple program, but it can't be compiled. What's wrong here? thanks, hunter #include <iostream>
2
by: shaun roe | last post by:
As a follow up to my question about STL and bitset<64> I'd like to share a quirk (bug?) about unsigned long long support and the bitset. I'm using gcc 3.2 on linux or gcc 3.3 on mac, the answer is...
5
by: SpOiLeR | last post by:
Hi. q1: Is std::bitset<N> part of standard or it's compiler extension? q2: Is std::bitset::to_string() part of standard? q3: My documentation say this about std::bitset::to_string(): ...
5
by: Rich S. | last post by:
Hi, Is the code below the best way to have the less than function for an 80 bit bitset or is there something faster / better? When I populate this map with millions (... and millions) of sets...
14
by: Haro Panosyan | last post by:
How to construct a bitset from string? For example: std::bitset<16> b16("1011011110001011"); Is this possible? Thanks in advance. -haro
3
by: shaun | last post by:
I have a function for returning the value of a bit field in a number: template<typename T> T bitfield(const T num, const unsigned int bitStart, const unsigned int bitEnd){ T mask,...
4
by: Sarath | last post by:
>From the documentation of MSDN, it is saying that bitset is not a STL container Unlike the similar vector<boolClass, the bitset class does not have iterators and is not an Standard Template...
2
by: arnuld | last post by:
i am confused on some aspects of bitset class: /* C++ Primer 4/e * chapter 3 * * exercise 3.23 * */ #include <iostream>
5
by: swcamry | last post by:
class bitset::reference { friend class bitset; reference(); // no public constructor public: ~reference(); operator bool () const; //...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.