Rick Measham wrote:
> 
> On 3 Mar 2004, at 1:48 AM, Reinhold May wrote:
> >> Flavio said:
> >> I don't think it is advisable to do that.
> >> Note that the data structure becomes much more
> >> complex as you start doing operations like
> >> union/intersection/complement/...
> >
> > If it's not advisable, is it feasible?  I mean, is there  a  way
> > to get the original set information from a spanset.   If  so,  I
> > guess, it would even make the new structure less complex.
> 
> I think this is what I was looking for this a while back. I've only
> just started reading this thread so I could be completely of the track.
> 
> Currently if I have:
> $this_year = span 2004-01-01 to 2004-12-31
> $today     = span 2004-03-03
> 
> And I put them into a spanset, then all I can retrieve is a span
> equivelent to $this_year.
> 
> However what I wanted to do was to be able to 'discover' that $now was
> a part of both $this_year and $today.
> 
> What I'm working on at the moment is not using spanset, but just a hash
> of spans and spansets:
> $calendar = {
>         'sundays'   => spanset of sundays,
>         'today'     => span of today,
>         'this_year' => span of this year,
>         'sunrise'   => set of datetimes
> }
> 
> But then, when I throw $now at it, I have to loop over every element in
> the hash looking for an intersection.
> 
> So what I did next was to create a single spanset every time $calendar
> was altered. That spanset is basically a merge of all elements of the
> hash, so now I can just see if $now intersects $total_span_set.
> 
> If it does I loop through the hash looking for events that contain $now.
> 
> All this, however, takes time. Is there a better way to do all this?
> What if I sort the hash by startdate and then binary search? Surely the
> sort will take more time than a loop search.
> 

I'm working on the lookup problem right now :) 
See the other thread - "RFC: DateTime::Event::Spreadsheet"

The latest sample implementation is 
http://www.ipct.pucrs.br/flavio/perl/DateTime-Event-Spreadsheet-0.00_05.pl

I'm not sure what's the best way to optimize the lookup, yet.
I've done some optimizations in (obsolete module) Date::Set::Timezone
that may be usable here.

- Flavio S. Glock

Reply via email to