On Sat, 15 Mar 2003 [EMAIL PROTECTED] wrote:
> I'm not sure of how the DateTime::Set iterator should behave.
>
> Would you give me an example? I've got a sketch:
>
> if ( $set->is_infinite ) {
> warn "this is an infinite set";
> print "first date is ", $set->min;
> print "second date is " ....
> print "last date is ", $set->max;
> }
> else {
> while ( .... ) {
> print "date: " ....
> ... next ...
> }
> }
>
> ----
> Note: Set::Infinite iterates using
> ($head, $tail) = $set->first;
> where $head is the first date, and $tail is the
> remainder of the set. The set is not modified by this
> operation.
>
> Another option would be:
> $head = $set->next;
> where $head is the first date, and it is removed from
> the set.
I was thinking of something like this actually:
my $iterator = $set->iterator
while ( my $dt = $iterator->next ) { ... }
The iterator() method may need to take some parameters, like "start" and
"end" for infinite sets, as well possible a direction parameter as well.
It will return an object of the DateTime::Set::Iterator class, though it's
possible there will be a need for multiple subclasses of that class (I
don't know yet).
BTW, how does Set::Infinite decide the "min" and "max" elements for an
infinite set? Obviously, min and max methods for the set are useful.
Does DateTime::Set get that for free from Set::Infinite?
-dave
/*=======================
House Absolute Consulting
www.houseabsolute.com
=======================*/