From: Phil Garofalo (pfg23_at_[hidden])
Date: 2002-06-13 12:57:21
I guess dynamic_bitset is the alternative I'm looking
for. As Rosanne Rosanna Danna said, "...Never mind!"
Confidential to moderator: if you would be so kind as
to not post these this message and my previous one
(see below)? Please! :-)
--- Phil Garofalo <pfg23_at_[hidden]> wrote:
> Date: Thu, 13 Jun 2002 10:39:18 -0700 (PDT)
> From: Phil Garofalo <pfg23_at_[hidden]>
> Subject: Re: [boost] Removing vector<bool>
> To: boost_at_[hidden]
> At 09:23 AM 6/13/2002 +1000, Matthew Wilson wrote:
> >It seems like a good idea to just remove it from
> next version of
> >standard if there are no significant (or vocal)
> of it
> I know vector<bool> doesn't adhere to the canonical
> container interface and I've read Scott Meyer's
> critique of it in _Effective STL_, but I for one
> like to see it stay. I believe there is a need for a
> space efficient, variably sized array of bit flags.
> bitset's size must be defined at runtime, as are the
> bit field structures, and Meyer's suggested
> deque<bool> seems grievously space inefficient. A
> simple case where vector<bool> seems perfectly
> is in an implementation of Eratosthene's Sieve.
> main (int argc,char** argv)
> if (argc < 2)
> cerr << "Usage: " << argv << " number" <<
> return EXIT_FAILURE;
> vector<bool> flags(strtoul(argv, NULL, 10) + 1,
> true); // set all flags true
> // Only need to go up to the square root.
> for(unsigned long i = 2; i < sqrt(flags.size());
> if (flags[i]) // found a prime
> for (unsigned long k = i + i; k <
> k += i)
> flags[k] = false; // cancel its multiples
> for (/*unsigned long*/ i = 2; i < flags.size();
> if (flags[i])
> cout << setw(11) << i;
> return EXIT_SUCCESS;
> If there's a better alternative to vector<bool> for
> cases like these, where you might need a very large
> number of flags dynamically allocated at run time,
> all for it. I haven't seen one yet. So until then, I
> vote to keep vector<bool>.
> Phil Garofalo
> Chicago, IL
> Do You Yahoo!?
> Yahoo! - Official partner of 2002 FIFA World Cup
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk