Boost logo

Boost :

From: Fernando Cacciola (fcacciola_at_[hidden])
Date: 2002-06-13 10:11:06


First, I think this library should be accepted into boost.

I don't mind that it diverges from vector<bool>. I've never liked it anyway
:-)

I thing there are two possible kind of 'collection' of bits.

One kind is a container of bits: that is, a sequence of bits that you
manipulate like you would with a container of anything else. You would, for
instance, insert, remove or incrementally add elements (bits) in the
sequence. This is what I think vector<bool> is for.

Another kind is a "bit-set". It is a collection but not a container in the
usual sense. A bit-set is typically of fixed size, set either at compile
time or upon construction. You wouldn't insert or remove bits from a
bit-set, and only occasionally you would append bits at the end. You might
want to iterate through the bits to use 'some' algorithms, but I don't
consider this really critical for the typical uses of bit-sets.

So, I think dyn_bitset<> is properly modeled and it isn't competing with
vector<bool> (though that wouldn't be a real problem).

If somewhat fast iterators can be added, then add them.. but I wouldn't mind
if they are not supported at all.

I have two comments on dyn_bitset<> (so far):

1) Why is 'flip' not named 'toggle'?
(In the implementation, you can see that it was formerly called toggle:-)

2) What's the rationale for to_long()? How does it work if block_type isn't
'unsigned long', and how does it work if the set contains N blocks (N>1)?
I understand that I might want to get an integral representation of all the
bits in the set, but to_long() might fall short of that task.
I'll prefer something like:

template<class Integral> Integral to_integral() const ;

which returns a value of type Integral which as much bits from the set as
possible.

Fernando Cacciola
Sierra s.r.l.
fcacciola_at_[hidden]
www.gosierra.com


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk