Boost logo

Boost :

From: Gennaro Prota (gennaro_prota_at_[hidden])
Date: 2003-08-19 05:18:53


--- Alexander Nasonov <alnsn-mycop_at_[hidden]> wrote:
> Google shows me a few links about bit_iterator.
>
> http://lists.boost.org/MailArchives/boost/msg03435.php
> http://groups.yahoo.com/group/Boost-Users/message/994
>
> Any progress since these messages have been posted?
>
> Definitely, I have an interest in bit_iterator. But I don't have enough time
> to implement it :(

I understand that it is not the same thing you want here, but dynamic_bitset
will have two functions, find_first and find_next, which allow iteration upon
"on" bits (see the sandbox). I'm not sure that having an "iterator interface"
is a good idea, since the class wouldn't satisfy the iterator requirements
anyway (proxy). In any case, it's trivial to construct a "dynamic_bitset
pseudo-iterator" based on those functions. Internally the two functions work on
an array of Blocks. Note that you can't work on "raw memory" in the sense that
you ignore the type of the objects and treat them as sequences of unsigned
chars: that's because you could end up treating padding bits = 1 as "real bits"
(value bits). So, using a "typed array" is probably the best way to go (if the
element type has padding you can see that at compile time). The implementation,
actually, is trivial: in my case, I simply find the first element of the array
!= 0 and then compute a log to base 2.

Genny.

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com


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