SPL-StandardPHPLibrary
Public Member Functions
InfiniteIterator Class Reference
Inheritance diagram for InfiniteIterator:
Inheritance graph
[legend]
Collaboration diagram for InfiniteIterator:
Collaboration graph
[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:
funcName of method to invoke
paramsArray of parameters to pass to method

Definition at line 110 of file iteratoriterator.inc.

    {
        return call_user_func_array(array($this->iterator, $func), $params);
    }
IteratorIterator::current ( ) [inherited]
Returns:
current value

Implements Iterator.

Definition at line 86 of file iteratoriterator.inc.

    {
        return $this->iterator->current();
    }
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().

    {
        return $this->iterator;
    }
IteratorIterator::key ( ) [inherited]
Returns:
current key

Implements Iterator.

Definition at line 79 of file iteratoriterator.inc.

    {
        return $this->iterator->key();
    }
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().

    {
        $this->getInnerIterator()->next();
        if (!$this->getInnerIterator()->valid())
        {
            $this->getInnerIterator()->rewind();
        }
    }

Here is the call graph for this function:

IteratorIterator::rewind ( ) [inherited]

rewind to the first element

Implements Iterator.

Reimplemented in NoRewindIterator.

Definition at line 100 of file iteratoriterator.inc.

    {
        return $this->iterator->rewind();
    }
IteratorIterator::valid ( ) [inherited]
Returns:
whether the iterator is valid

Implements Iterator.

Definition at line 72 of file iteratoriterator.inc.

Referenced by next().

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

The documentation for this class was generated from the following file: