|
Boost : |
From: Victor A. Wagner, Jr. (vawjr_at_[hidden])
Date: 2002-07-29 11:35:54
It seems to me that if we're seriously going to consider adding "set
semantics" to some set (pun intended) of classes; we could do a lot worse
than look at a language that actually had set as part of its fundamental
design (Pascal).
IIRC Pascal (and I belive, Modula) sets supported the following operators
-(unary) not (flip all truth elements in the set)
+ union (C++ would probably use |)
* intersection (C++ would probably use &)
- difference .... a - b is equivalent to a * (-b)
xor(^) bit for bit ^
in set membership (usage: if y in myset then.....)
<= proper subset
>= proper superset
= equality (in C++ we use ==)
<> inequality (in C++ we use !=)
all sets were "bounded" i.e. had a defined lower and upper bound of
possible members.
IMO, there are good reasons to provide operators instead of just standard
functions especially if an algebraic notation already exists for the
concept. for example, it's a _lot_ easier to write
a = b ^ c;
than
a.clear();
set_symmetric_difference(b.begin(), b.end(), c.begin(), c.end(),
back_inserter(a));
//or whatever one would have to write to get the equivalent of
back_inserter() for a set.
At Monday 2002/07/29 08:37, you wrote:
>Hi Dave,
>
>On Sat, 27 Jul 2002, David Abrahams wrote:
>dave> How about operator-() for set difference? That seems like an obvious
>dave> need...
>
>One small problem with this is that one metaphor for dynamic_bitset is
>that of a big integer. All the current operators are borrowed from the
>builtin operators on an unsigned int. The problem is that operator-
>doesn't mean set difference for unsigned int, but subtraction.
>
>One idea I've had in the past is to create a "Set" concept, which would
>include things like union, difference, intersection, etc. For the general
>idea of what the interface would look like, see:
>
>boost/graph/detail/set_adaptor.hpp
>
>Under this framework, it would make sense to implement this "Set"
>interface for dynamic_bitset, in addition to other classes that can be
>thought of as implementing sets, such as std::set.
>
>Cheers,
>Jeremy
>
>
>----------------------------------------------------------------------
> Jeremy Siek http://php.indiana.edu/~jsiek/
> Ph.D. Student, Indiana Univ. B'ton email: jsiek_at_[hidden]
> C++ Booster (http://www.boost.org) office phone: (812) 855-3608
>----------------------------------------------------------------------
>
>
>_______________________________________________
>Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Victor A. Wagner Jr. http://rudbek.com
PGP RSA fingerprint = 4D20 EBF6 0101 B069 3817 8DBF C846 E47A
PGP D-H fingerprint = 98BC 65E3 1A19 43EC 3908 65B9 F755 E6F4 63BB 9D93
The five most dangerous words in the English language:
"There oughta be a law"
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk