InfiniteIterator Class Reference
[Internal classes]

An infinite Iterator. More...

Inheritance diagram for InfiniteIterator:

Inheritance graph
{IteratorIterator\n|- $iterator\l|+ __call()\l+ __construct()\l+ current()\l+ getInnerIterator()\l+ key()\l+ next()\l+ rewind()\l+ valid()\l}{OuterIterator\n||+ getInnerIterator()\l}{Iterator\n||+ current()\l+ key()\l+ next()\l+ rewind()\l+ valid()\l}{Traversable\n||}
[legend]
Collaboration diagram for InfiniteIterator:

Collaboration graph
{IteratorIterator\n|- $iterator\l|+ __call()\l+ __construct()\l+ current()\l+ getInnerIterator()\l+ key()\l+ next()\l+ rewind()\l+ valid()\l}{OuterIterator\n||+ getInnerIterator()\l}{Iterator\n||+ current()\l+ key()\l+ next()\l+ rewind()\l+ valid()\l}{Traversable\n||}
[legend]
List of all members.

Public Member Functions

 __call ($func, $params)
 current ()
 getInnerIterator ()
 key ()
 next ()
 rewind ()
 valid ()

Detailed Description

An infinite Iterator.

Author:
Marcus Boerger
Version:
1.1
Since:
PHP 5.1
This Iterator takes another Iterator and infinitvely iterates it by rewinding it when its end is reached.

Note:
Even an InfiniteIterator stops if its inner Iterator is empty.
 $it       = new ArrayIterator(array(1,2,3));
 $infinite = new InfiniteIterator($it);
 $limit    = new LimitIterator($infinite, 0, 5);
 foreach($limit as $val=>$key)
 {
 	echo "$val=>$key\n";
 }
 

Definition at line 33 of file infiniteiterator.inc.


Member Function Documentation

IteratorIterator::__call ( func,
params 
) [inherited]

Aggregate the inner iterator.

Parameters:
func Name of method to invoke
params Array of parameters to pass to method

Definition at line 110 of file iteratoriterator.inc.

00111     {
00112         return call_user_func_array(array($this->iterator, $func), $params);
00113     }

IteratorIterator::current (  )  [inherited]

Returns:
current value

Implements Iterator.

Definition at line 86 of file iteratoriterator.inc.

00087     {
00088         return $this->iterator->current();
00089     }

IteratorIterator::getInnerIterator (  )  [inherited]

Returns:
the inner iterator as passed to the constructor

Implements OuterIterator.

Definition at line 65 of file iteratoriterator.inc.

Referenced by next().

00066     {
00067         return $this->iterator;
00068     }

IteratorIterator::key (  )  [inherited]

Returns:
current key

Implements Iterator.

Definition at line 79 of file iteratoriterator.inc.

00080     {
00081         return $this->iterator->key();
00082     }

InfiniteIterator::next (  ) 

Move the inner Iterator forward to its next element or rewind it.

Returns:
void

Reimplemented from IteratorIterator.

Definition at line 38 of file infiniteiterator.inc.

References IteratorIterator::getInnerIterator(), and IteratorIterator::valid().

00039     {
00040         $this->getInnerIterator()->next();
00041         if (!$this->getInnerIterator()->valid())
00042         {
00043             $this->getInnerIterator()->rewind();
00044         }
00045     }

Here is the call graph for this function:

IteratorIterator::getInnerIteratorIteratorIterator::valid

IteratorIterator::rewind (  )  [inherited]

rewind to the first element

Implements Iterator.

Reimplemented in NoRewindIterator.

Definition at line 100 of file iteratoriterator.inc.

00101     {
00102         return $this->iterator->rewind();
00103     }

IteratorIterator::valid (  )  [inherited]

Returns:
whether the iterator is valid

Implements Iterator.

Definition at line 72 of file iteratoriterator.inc.

Referenced by next().

00073     {
00074         return $this->iterator->valid();
00075     }


The documentation for this class was generated from the following file:
Generated on Thu Apr 26 01:05:51 2007 for SPL-StandardPHPLibrary by  doxygen 1.5.2