1<?php 2 3/** @file seekableiterator.inc 4 * @ingroup SPL 5 * @brief class SeekableIterator 6 * @author Marcus Boerger 7 * @date 2003 - 2009 8 * 9 * SPL - Standard PHP Library 10 */ 11 12/** @brief seekable iterator 13 * @author Marcus Boerger 14 * @version 1.0 15 * @since PHP 5.0 16 * 17 * Turns a normal iterator ino a seekable iterator. When there is a way 18 * to seek on an iterator LimitIterator can use this to efficiently rewind 19 * to offset. 20 */ 21interface SeekableIterator extends Iterator 22{ 23 /** Seek to an absolute position 24 * 25 * \param $index position to seek to 26 * \return void 27 * 28 * The method should throw an exception if it is not possible to seek to 29 * the given position. Typically this exception should be of type 30 * OutOfBoundsException. 31 \code 32 function seek($index); 33 $this->rewind(); 34 $position = 0; 35 while($position < $index && $this->valid()) { 36 $this->next(); 37 $position++; 38 } 39 if (!$this->valid()) { 40 throw new OutOfBoundsException('Invalid seek position'); 41 } 42 } 43 \endcode 44 */ 45 function seek($index); 46} 47 48?>