G'day Flavio,

I'm doing some intensive SpanSet stuff and I'm thinking you might be
able to answer a couple of questions:

I'm trying to get next/previous spans from a given DateTime. I'm
defining next/previous as the event who started before or after $dt.
Where it ends doesn't matter, even if we're still in the middle of the
event.

To get the 'next' I'm intersecting with a span starting at $dt and
ending at +inf. Then I get $iterator->next. I return it unless the
spanset contains $dt. If it does then I return $iterator->next.

This seems a lot to do to get the next span after a particular $dt.

However, to get the previous is even worse!

Once again I intersect with -inf to $dt. Then if the spanset contains
$dt, I get the max of the complement of the intersection. This is the
start of the span I want. Now to get then end of it, I can't see any
other way than to intersect the original span with $dt to +inf. Which
seems like craziness to me!

If we're not in the middle of a span, it goes on! First I get the max of
the -inf to $dt spanset intersection. That's the end of the span I want,
lets call that $dt2. I then get the max of the complement of -inf to
$dt2, that's the start of the span.

All the above takes time. Seconds in fact! Surely there's a better way
... I'd really like to have $spanset->next_span($dt) and
$spanset->previous_span($dt) but if there's some way to do it myself
that is better than what I'm doing I'd love to know.

Thanks and Cheers!
Rick Measham

Reply via email to