Boost logo

Boost :

From: Gennaro Prota (gennaro_prota_at_[hidden])
Date: 2004-04-14 04:06:11


On Wed, 14 Apr 2004 09:34:14 +0200, Gennaro Prota
<gennaro_prota_at_[hidden]> wrote:

>I also added
>the following functions: find_first, find_next, get_allocator(),
>max_size(), intersects() and empty().

The function intersects() was a user request. It returns true if and
only if the two bitsets have any bit "in common", i.e.:

a.intersects(b) == true <=> An index i < a.size(), b.size() exists
                            such as a[i] == true and b[i] == true

Logically, this is the same as doing (a & b).any() [except that
currently a & b requires the two bitsets to have the same size - this
restriction will likely be removed in the future if we reach a
consensus on semantics] but is faster because it doesn't require any
copy and can be done with one pass through the blocks

I was thinking, however: what about returning the index of the first
bit in common (or npos), instead of true/false?

Secondly, does anyone find confusing that empty() means size() == 0
rather than "the set is empty"? Someone could be tempted to write e.g.

  if ((a ^ b).empty()) ...

instead of

  if ((a ^ b).none()) ...

Genny.


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