SPL-StandardPHPLibrary
Public Member Functions | List of all members
InfiniteIterator Class Reference
Inheritance diagram for InfiniteIterator:
Inheritance graph
Collaboration diagram for InfiniteIterator:
Collaboration graph

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.

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

Implements Iterator.

Definition at line 86 of file iteratoriterator.inc.

87  {
88  return $this->iterator->current();
89  }
IteratorIterator::getInnerIterator ( )
inherited
Returns
the inner iterator as passed to the constructor

Implements OuterIterator.

Definition at line 65 of file iteratoriterator.inc.

References IteratorIterator\$iterator.

Referenced by next().

66  {
67  return $this->iterator;
68  }
$iterator
The inner iterator must be private because when this class will be converted to c code it won't no lo...
IteratorIterator::key ( )
inherited
Returns
current key

Implements Iterator.

Definition at line 79 of file iteratoriterator.inc.

80  {
81  return $this->iterator->key();
82  }
InfiniteIterator::next ( )

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

Returns
void

Implements Iterator.

Definition at line 38 of file infiniteiterator.inc.

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

39  {
40  $this->getInnerIterator()->next();
41  if (!$this->getInnerIterator()->valid())
42  {
43  $this->getInnerIterator()->rewind();
44  }
45  }

Here is the call graph for this function:

IteratorIterator::rewind ( )
inherited

rewind to the first element

Implements Iterator.

Definition at line 100 of file iteratoriterator.inc.

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

Implements Iterator.

Definition at line 72 of file iteratoriterator.inc.

Referenced by next().

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

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