Intervals representation with brackets
| From: | Samuel ROZE | Date: | Fri, 20 Nov 2009 21:56:54 +0000 |
| Subject: | Intervals representation with brackets | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-46131@lists.php.net to get a copy of this message | ||
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.