1<?php 2 3/** @file infiniteiterator.inc 4 * @ingroup SPL 5 * @brief class InfiniteIterator 6 * @author Marcus Boerger 7 * @date 2003 - 2009 8 * 9 * SPL - Standard PHP Library 10 */ 11 12/** @ingroup SPL 13 * @brief An infinite Iterator 14 * @author Marcus Boerger 15 * @version 1.1 16 * @since PHP 5.1 17 * 18 * This Iterator takes another Iterator and infinitvely iterates it by 19 * rewinding it when its end is reached. 20 * 21 * \note Even an InfiniteIterator stops if its inner Iterator is empty. 22 * 23 \verbatim 24 $it = new ArrayIterator(array(1,2,3)); 25 $infinite = new InfiniteIterator($it); 26 $limit = new LimitIterator($infinite, 0, 5); 27 foreach($limit as $val=>$key) 28 { 29 echo "$val=>$key\n"; 30 } 31 \endverbatim 32 */ 33class InfiniteIterator extends IteratorIterator 34{ 35 /** Move the inner Iterator forward to its next element or rewind it. 36 * @return void 37 */ 38 function next() 39 { 40 $this->getInnerIterator()->next(); 41 if (!$this->getInnerIterator()->valid()) 42 { 43 $this->getInnerIterator()->rewind(); 44 } 45 } 46} 47 48?>