MediaWiki master
MappedIterator Class Reference

Convenience class for generating iterators from iterators. More...

Inherits FilterIterator.

Collaboration diagram for MappedIterator:

Public Member Functions

 __construct ( $iter, $vCallback, array $options=[])
 Build a new iterator from a base iterator by having the former wrap the later, returning the result of "value" callback for each current() invocation.
 
 accept ()
 
 current ()
 
 key ()
 
 next ()
 
 rewind ()
 
 valid ()
 

Protected Member Functions

 init ()
 Obviate the usual need for rewind() before using a FilterIterator in a manual loop.
 

Protected Attributes

callable null $aCallback
 
array $cache = []
 
bool $rewound = false
 whether rewind() has been called
 
callable $vCallback
 

Detailed Description

Convenience class for generating iterators from iterators.

Since
1.21

Definition at line 28 of file MappedIterator.php.

Constructor & Destructor Documentation

◆ __construct()

MappedIterator::__construct ( $iter,
$vCallback,
array $options = [] )

Build a new iterator from a base iterator by having the former wrap the later, returning the result of "value" callback for each current() invocation.

The callback takes the result of current() on the base iterator as an argument. The keys of the base iterator are reused verbatim.

An "accept" callback can also be provided which will be called for each value in the base iterator (post-callback) and will return true if that value should be included in iteration of the MappedIterator (otherwise it will be filtered out).

Parameters
Iterator | array$iter
callable$vCallbackValue transformation callback
array$optionsOptions map (includes "accept") (since 1.22)
Exceptions
UnexpectedValueException

Definition at line 55 of file MappedIterator.php.

References $vCallback.

Member Function Documentation

◆ accept()

MappedIterator::accept ( )

Definition at line 79 of file MappedIterator.php.

◆ current()

MappedIterator::current ( )

Definition at line 105 of file MappedIterator.php.

◆ init()

MappedIterator::init ( )
protected

Obviate the usual need for rewind() before using a FilterIterator in a manual loop.

Definition at line 117 of file MappedIterator.php.

◆ key()

MappedIterator::key ( )

Definition at line 92 of file MappedIterator.php.

◆ next()

MappedIterator::next ( )

Definition at line 68 of file MappedIterator.php.

◆ rewind()

MappedIterator::rewind ( )

Definition at line 73 of file MappedIterator.php.

◆ valid()

MappedIterator::valid ( )

Definition at line 98 of file MappedIterator.php.

Member Data Documentation

◆ $aCallback

callable null MappedIterator::$aCallback
protected

Definition at line 32 of file MappedIterator.php.

◆ $cache

array MappedIterator::$cache = []
protected

Definition at line 34 of file MappedIterator.php.

◆ $rewound

bool MappedIterator::$rewound = false
protected

whether rewind() has been called

Definition at line 37 of file MappedIterator.php.

◆ $vCallback

callable MappedIterator::$vCallback
protected

Definition at line 30 of file MappedIterator.php.

Referenced by __construct().


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