Boost logo

Boost :

From: Matias Capeletto (matias.capeletto_at_[hidden])
Date: 2007-02-28 17:17:55


On 2/28/07, John Maddock <john_at_[hidden]> wrote:
> Matias Capeletto wrote:
> > What are the reasons for this change?
> > (If it is changed I think we should call it bimap.above)
> >
> > I like the above view because the set of relations is handy (and
> > better suited) for general not directed task such as insertion (it is
> > more efficient in it than in the side views), iteration, questions as
> > size or empty. Why not to make it easily accessible?
> >
> > If you want to know the size and there is not such thing as the
> > relation view, what side would you choose? bimap.left.size()? What is
> > special about it?
> > bimap.size() is IMO a better way to express in the code your
> > intention.
>
> First off I confess that I'm not completely set on this change - just that
> it's one possible solution to a recurring theme among reviewers. The
> rationale is that it forces you to specify *which* view you're talking
> about. Maybe an alternative would perhaps be to document bimap from the
> start as a "container of relations that also offers left/right associative
> views".

It can be an option. But there are some issues with the actual default
set type of relations for this view. It is left_based. This introduced
an asymmetry and is not a very good idea to present this view as the
principal one.

Being left based means that it uses the left side view to build the
set type of relation. The elements are stored in the same way that in
the left map. The left element is the only one used internally as a
key for indexing ( relation(1,0.1) and relation(1,0.2) are equal to
the compare functor. ) This save us a B.MI index and is mandatory for
performance reasons. The only way to make this view symmetric is to
use unconstrained_set_of_relation as the default, but we will get back
to the first scenario where we the only way to work with the mapping
is through the side views. IMO if the docs clearly show the asymmetry
of the left_based default it is better to choose it over
unconstrained_set_of_relation.

This is why I think it is better to present the bimap as the
composition of two complementary signature-compatible std::maps. And
later introduce the set view of relations as another way to see the
mapping. We have to see if it is good to talk about this issues in the
one minute tutorial.

> BTW "above" is a terrible name: call a relation a relation IMO :-)

I was looking for something that follow the .left and .right notation.
The "above" view is a synonym of the set of relations in the docs.

Regards
Matias


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