On Mon, Apr 03, 2000 at 10:34:35PM +0200, Lars Gullik Bj&resh;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?

> 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.

Reply via email to