Boost logo

Boost :

From: Herve Bronnimann (hbr_at_[hidden])
Date: 2002-09-26 13:49:42


On Thu, Sep 26, 2002 at 10:38:45AM -0400, Eric Woodruff wrote:
> There is a lot of support for iterators, but I needed something numerical,
> not iterator-based.

And Doug gregor wrote:
> The recently-accepted Interval arithmetic library does range
> intersection, but not for std::pair.

If it's numerical, then I suspect you don't really intend to represent
your range with std::pair, consider using boost::interval<T> instead.
Unlike pair, the semantic of an interval is what you mean here.

Intersections will work fine using intersection(i1, i2). If your intent
is to model open intervals, you'll have to ask Guillaume Melquiond what
the comparison scheme is to handle those, but I recall from the review
that it can be done.

If you also need to represent union of intervals, then, you'll have to manage
this one on your own, but the building block interval<T> is already done
so all you need to worry about is a sorted container of them
(presumably, your intervals will be disjoint and then totally ordered;
you'll have to worry about merging non-disjoint intervals in your
container... for this, you'd use the function hull(i1,i2).)

Best,

-- 
Herve'

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