Boost logo

Boost :

Subject: Re: [boost] Review Request: Boost.Itl; The Interval Template Library
From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2009-09-24 23:48:52


On Thu, Sep 24, 2009 at 10:13 AM, Joachim Faulhaber
<afojgo_at_[hidden]> wrote:
> 2009/9/24 Joachim Faulhaber <afojgo_at_[hidden]>:
>> 2009/9/24 Gottlob Frege <gottlobfrege_at_[hidden]>:
>>> As an example usage, with your library, how would you write a 'for a
>>> given interval_set, is this time-range [a, b) empty' function?
>>>
>> I am not sure if I understand exactly what you mean here ... but
>>
>> // This code checks if an interval_set is empty within a range.
>> interval_set<time> some_times;
>> some_times += ...; time a = ..., b = ...;
>> if(intersects(some_times, interval<int>::rightopen(a,b)))
>>    ; // Within the range [a,b) some_times is not empty
>>
>
> Correction: must be interval<time> of course
>
> // This code checks if an interval_set is empty within a range.
> interval_set<time> some_times;
> some_times += ...; time a = ..., b = ...;
> if(intersects(some_times, interval<time>::rightopen(a,b)))
>   ; // Within the range [a,b) some_times is not empty

That's exactly what I meant, and expected something like that, but
just thought I'd check. Thanks. In my code-base, writing yet-another
IsEmpty(starttime, endtime) member function is what made me realize
that it should be a general library with reusable algorithms.

I take it I could make the intersects() algorithm (and all the others)
work with my existing data structures (the same way stl algorithms
work with anything that has the right iterators)? (And then possibly
move to interval_sets later?)

Tony


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