Subject: Re: [Boost-bugs] [Boost C++ Libraries] #5482: iterative_size() not the same for interval_maps using std::less and std::greater
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-04-17 16:50:32
#5482: iterative_size() not the same for interval_maps using std::less and
std::greater
-------------------------------------+--------------------------------------
Reporter: boicotinho@⦠| Owner: jofaber
Type: Bugs | Status: assigned
Milestone: Boost 1.47.0 | Component: ICL
Version: Boost 1.46.1 | Severity: Problem
Resolution: | Keywords: interval, iteration, ordering
-------------------------------------+--------------------------------------
Comment (by jofaber):
Replying to [comment:3 anonymous]:
> Replying to [comment:2 jofaber]:
>
> Thank you for looking into this -
> I really like this ICL of yours and use it a lot :)
That's nice to hear. For me it is good to have users who are challenging
the library or use it creative ways, so we can detect flaws and improve
the code.
> FYI It seems that your workaround works - but if
> I insert the intervals in another order for m2,
> then m2.find() fails while m1.find() still works.
True, I suspected you'd find some more problems using std::greater. I have
found and fixed more inconsistencies between compare-order and
incrementation/decrementation that caused these program failures and
committed the improved code to the boost/trunk. You might want to get a
copy of that code if you like. I am still doing some testing though before
closing the ticket.
> In the meanwhile I am using std::less but representing
> the data with negative numbers instead.
>
> The reason I wanted to use std::greater is because
> I would like find() to start from the highest interval
> given a range.
To find the last interval that overlaps a given interval `I` you could use
`it = m.upper_bound(I)`, which yields an iterator to the first interval
that is greater than I and then decrement the iterator `it` once.
Cheers,
Joachim
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/5482#comment:4> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:06 UTC