
On Thu, Sep 24, 2009 at 10:13 AM, Joachim Faulhaber <afojgo@googlemail.com> wrote:
2009/9/24 Joachim Faulhaber <afojgo@googlemail.com>:
2009/9/24 Gottlob Frege <gottlobfrege@gmail.com>:
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