Re: Intervals representation with brackets
| From: | mm w | Date: | Fri, 20 Nov 2009 22:07:54 +0000 |
| Subject: | Re: Intervals representation with brackets | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-46133@lists.php.net to get a copy of this message | ||
http://code.google.com/p/foundation-kit/source/browse/trunk/FKRange.php
http://code.google.com/p/foundation-kit/source/browse/trunk/FKIndexSet.php
On Fri, Nov 20, 2009 at 1:56 PM, Samuel ROZE <samuel.roze@gmail.com> wrote:
> Hello,
>
> I'm working on two classes, Interval and IntervalList which describe
> an interval and a list of intervals. These intervals are defined using
> the Interval class:
>
> <?php
> $interval = new Interval((int) $from, (int) $to);
> ?>
>
> These intervals can be stored in a list of intervals, using IntervalList:
>
> <?php
> $list = new IntervalList();
> $list->add($interval_1);
> $list->add($interval_2);
> ?>
>
> IntervalList's functions are:
> - inverse(); which returns an IntervalList object
> - intersection(); which returns an IntervalList object of intervals
> which are contained by every interval of this list.
>
> To be easier, what do you think about:
> <?php
> // An interval with [ & ]
> $interval = [ (int) $from, (int) $to ];
> ?>
>
> <?php
> // A list of intervals
> $list = [ $from_1, $to_1] + [$from_2, $to_2] + ... [$from_n, $to_n];
> $list_2 = [$from_1, $to_1] + ... + $interval_n;
> ?>
>
> Regards,
> Samuel ROZE.
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>