Boost logo

Boost :

From: David Abrahams (abrahams_at_[hidden])
Date: 2001-06-11 21:46:22

----- Original Message -----
From: "Andrew Lumsdaine" <lums_at_[hidden]>

> One thing Jeremy and I had tossed around some time ago while trying to get
> handle on what is a matrix is that a matrix could be viewed as a
> doubly-indexed associative container. If this seems like an interesting
> reasonable view of a matrix, then the iterator interface might look
> something like std::map, but in this case the value type would be a triple
> (key1, key2, value) instead of a pair. The tuple library might have some
> bearing on the interface in this case.
> So here is a question. Are the following semantically equivalent (is the
> difference only syntax)? Is there any reason to choose one over the
> *i.first
> row(*i)
> row(i)
> *i.second
> col(*i)
> col(i)
> *i.third
> val(*i)
> val(i)

The *i.whatever syntax imposes a strong requirement that there be an lvalue
somewhere with members first,second,third. I dislike it for that reason.

the row(*i) syntax makes the strong implication that the row is a property
of the referent of the iterator, rather than of the iterator itself. That
isn't accurate in most cases; I dislike it for that reason.

> I think the third option (row(i), col(i), val(i)) makes for the more
> case of a triple, but perhaps it would be too general?

Previous examples have all shown how to access attributes of a position in
the matrix. The above is an example of how to do the opposite: form some
composite of all those attributes. I dislike it, or hope it's irrelevant in
part because I hope that for many matrices (e.g. dense ones) there would
never be a need to compose such a value.

> Again, it might be interesting to throw some algorithms around to see if
> anything interesting falls out in comparing and contrasting these.

Do you mean to suggest that we implement some algorithms in terms of the
proposed syntaxes? Sounds OK, although I'm afraid it would take something
extraordinary to make me interested in any of the syntaxes other than
row(i)... it might not be worth the trouble just for this small decision,
which after all could be changed later.

Full of dislikes and opinions tonight,

Boost list run by bdawes at, gregod at, cpdaniel at, john at