Dekel Tsur <[EMAIL PROTECTED]> writes:
| On Mon, Apr 03, 2000 at 10:34:35PM +0200, Lars Gullik Bjønnes wrote:
| > +inline bool operator<(LyXParagraph::InsetTable const & a,
| > + LyXParagraph::InsetTable const & b)
| > +{
| > + return a.pos < b.pos;
| > +}
| >
| > This one looks conceptually wrong.
| > When comparing two InsetTables you need to take pos into account.
| > Instead of using this operator< (I assume you add this because of
| > lowerbound) create an appropriate functor
| >
| > struct compare_insettable_pos {
| > public:
| > inline bool operator()(LyXParagraph::InsetTable const & a,
| > LyXParagraph::InsetTable const & b) const
| > {
| > return a.pos < b.pos;
| > }
| > }
|
| I used the former to save some typing. Why should I use the latter?
As I said... to be conceptually more correct.
Also if we sometime in the future would like to compare InsetTables in
other ways taking the inset into account.
And you didn't save a lot of typing either. I am sure you even can
figure out a name for the functor that is shorter than
"InsetTable(pos, 0)".
|
| > btw. why a vector for InsetTable? I would thing that a list suited the
| > sorted/kept sorted sequence a lot better.
|
| Because lowerbound() takes logarithmic time for a sorted vector, but it is
| linear time for a sorted list.
hmm da hmm...
but insertion is O(n)... what about a std::set?
Lgb