|
SPL-StandardPHPLibrary
|


Public Member Functions | |
| __call ($func, $params) | |
| __construct (Traversable $iterator, $classname=null) | |
| current () | |
| getInnerIterator () | |
| key () | |
| next () | |
| rewind () | |
| valid () | |
Private Attributes | |
| $iterator | |
Basic Iterator wrapper.
This iterator wrapper allows to convert anything that is traversable into an Iterator. It is very important to understand that most classes that do not implement Iterator have their reasone to. Most likely they do not allow the full Iterator feature set. If so you need to provide techniques to prevent missuse. If you do not you must expect exceptions or fatal errors.
It is also possible to derive the class and implement IteratorAggregate by downcasting the instances returned in getIterator. See the following example (assuming BaseClass implements Traversable):
As you can see in the example this approach requires that the class to downcast to is actually a base class of the specified iterator to wrap. Omitting the downcast in the above example would result in an endless loop since IteratorIterator::__construct() would call SomeClass::getIterator().
Definition at line 40 of file iteratoriterator.inc.
| IteratorIterator::__construct | ( | Traversable | $iterator, |
$classname = null |
|||
| ) |
Construct an IteratorIterator from an Iterator or an IteratorAggregate.
| iterator | inner iterator |
| classname | optional class the iterator has to be downcasted to |
Definition at line 47 of file iteratoriterator.inc.
References $iterator.
| IteratorIterator::__call | ( | $func, | |
| $params | |||
| ) |
Aggregate the inner iterator.
| func | Name of method to invoke |
| params | Array of parameters to pass to method |
Definition at line 110 of file iteratoriterator.inc.
| IteratorIterator::current | ( | ) |
| IteratorIterator::getInnerIterator | ( | ) |
Implements OuterIterator.
Definition at line 65 of file iteratoriterator.inc.
References $iterator.
Referenced by InfiniteIterator\next().
| IteratorIterator::key | ( | ) |
| IteratorIterator::next | ( | ) |
| IteratorIterator::rewind | ( | ) |
rewind to the first element
Implements Iterator.
Definition at line 100 of file iteratoriterator.inc.
| IteratorIterator::valid | ( | ) |
Implements Iterator.
Definition at line 72 of file iteratoriterator.inc.
Referenced by InfiniteIterator\next().
|
private |
The inner iterator must be private because when this class will be converted to c code it won't no longer be available.
Definition at line 118 of file iteratoriterator.inc.
Referenced by __construct(), and getInnerIterator().
1.8.5