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.
Cheers! Rick
Senior Developer PrintSupply - Print Procurement & Supply Management 18 Greenaway Street VIC 3105 Tel: (03) 9850 3255 Fx: (03) 9850 3277 http://www.printsupply.com.au/