PHP Interface Pinq\Iterators\IIteratorScheme

Author: Elliot Levin ([email protected])
Show file Open project: timetoogo/pinq Interface Usage Examples

Public Methods

Method Description
appendIterator ( Traversable $iterator, Traversable $otherIterator ) : Pinq\Iterators\IWrapperIterator Returns an iterator which will return all values from both the supplied iterators.
arrayCompatibleIterator ( Traversable $iterator ) : Pinq\Iterators\IWrapperIterator Returns an iterator which will map any non integer or string keys to incrementing integers.
arrayIterator ( array $array ) : Traversable Returns an iterator for the supplied array.
createOrderedMap ( Traversable $iterator = null ) : Pinq\Iterators\IOrderedMap Creates an ordered map from the supplied iterator.
createSet ( Traversable $iterator = null ) : Pinq\Iterators\ISet Creates an set from the supplied iterator values.
differenceIterator ( Traversable $iterator, Traversable $otherIterator ) : Pinq\Iterators\IWrapperIterator Returns an iterator which will return uniqe values present in the first but not the second iterator.
emptyIterator ( ) : Traversable Returns an empty iterator.
exceptIterator ( Traversable $iterator, Traversable $otherIterator ) : Pinq\Iterators\IWrapperIterator Returns an iterator which will return all values in the first but not present in the second iterator.
filterIterator ( Traversable $iterator, callable $predicate ) : Pinq\Iterators\IWrapperIterator Returns an iterator which will filter the elements according to the supplied predicate function.
flattenedIterator ( Traversable $iterator ) : Pinq\Iterators\IWrapperIterator Returns an iterator which will iterate each element of the inner iterator's values. An exception will be thrown if an invalid iterator is returned from the supplied iterator.
groupJoinIterator ( Traversable $outerIterator, Traversable $innerIterator, callable $traversableFactory ) : Pinq\Iterators\IJoinIterator Returns an iterator which will return the outer elements joined to the inner elements. All matched inner elements for each outer element will be wrapped in a traversable implementation from the supplied factory.
groupedIterator ( Traversable $iterator, callable $groupKeyFunction, callable $traversableFactory ) : Pinq\Iterators\IWrapperIterator Returns an iterator which will group the elements according to the supplied function and wrap each group in a traversable implementation from the supplied factory.
intersectionIterator ( Traversable $iterator, Traversable $otherIterator ) : Pinq\Iterators\IWrapperIterator Returns an iterator which will return unique values present in the first and second iterator.
joinIterator ( Traversable $outerIterator, Traversable $innerIterator ) : Pinq\Iterators\IJoinIterator Returns an iterator which will return the outer elements joined to the inner elements.
orderedIterator ( Traversable $iterator, callable $function, boolean $isAscending ) : Pinq\Iterators\IOrderedIterator Returns an iterator with will sort the elements according to the supplied function and direction.
projectionIterator ( Traversable $iterator, callable $keyProjectionFunction = null, callable $valueProjectionFunction = null ) : Pinq\Iterators\IWrapperIterator Returns an iterator which will return the elements mapped by the supplied functions or the original if no function is supplied.
rangeIterator ( Traversable $iterator, integer $start, integer | null $amount ) : Pinq\Iterators\IWrapperIterator Returns an iterator which will only iterate the elements in the supplied range.
reindexerIterator ( Traversable $iterator ) : Pinq\Iterators\IWrapperIterator Returns an iterator which will return the map the keys to 0-based incrementing integers
toArray ( Traversable $iterator ) : array Safely converts the supplied iterator to an array.
toIterator ( Traversable | array $traversableOrArray ) : Traversable Returns the supplied traversable or array as an iterator compatible with this scheme.
unionIterator ( Traversable $iterator, Traversable $otherIterator ) : Pinq\Iterators\IWrapperIterator Returns an iterator which will return unique values present in the first or second iterator.
uniqueIterator ( Traversable $iterator ) : Pinq\Iterators\IWrapperIterator Returns an iterator which will return unique values using strict equality.
uniqueKeyIterator ( Traversable $iterator ) : Pinq\Iterators\IWrapperIterator Returns an iterator which will return only the first associated value for any key.
walk ( Traversable $iterator, callable $function ) : void Iterate over the keys and values of the supplied iterator and passes them (value, key) to the supplied function.
whereInIterator ( Traversable $iterator, Traversable $otherIterator ) : Pinq\Iterators\IWrapperIterator Returns an iterator which will return all values in the first iterator present in the second.

Method Details

appendIterator() public method

Returns an iterator which will return all values from both the supplied iterators.
public appendIterator ( Traversable $iterator, Traversable $otherIterator ) : Pinq\Iterators\IWrapperIterator
$iterator Traversable
$otherIterator Traversable
return Pinq\Iterators\IWrapperIterator

arrayCompatibleIterator() public method

Returns an iterator which will map any non integer or string keys to incrementing integers.
public arrayCompatibleIterator ( Traversable $iterator ) : Pinq\Iterators\IWrapperIterator
$iterator Traversable
return Pinq\Iterators\IWrapperIterator

arrayIterator() public method

Returns an iterator for the supplied array.
public arrayIterator ( array $array ) : Traversable
$array array
return Traversable

createOrderedMap() public method

Keys can only be associated with a single value and such if the iterator returns duplicate keys the last respective value will be used.
public createOrderedMap ( Traversable $iterator = null ) : Pinq\Iterators\IOrderedMap
$iterator Traversable
return Pinq\Iterators\IOrderedMap

createSet() public method

A set can only contain unique values and such duplicates will be lost.
public createSet ( Traversable $iterator = null ) : Pinq\Iterators\ISet
$iterator Traversable
return Pinq\Iterators\ISet

differenceIterator() public method

Returns an iterator which will return uniqe values present in the first but not the second iterator.
public differenceIterator ( Traversable $iterator, Traversable $otherIterator ) : Pinq\Iterators\IWrapperIterator
$iterator Traversable
$otherIterator Traversable
return Pinq\Iterators\IWrapperIterator

emptyIterator() public method

Returns an empty iterator.
public emptyIterator ( ) : Traversable
return Traversable

exceptIterator() public method

Returns an iterator which will return all values in the first but not present in the second iterator.
public exceptIterator ( Traversable $iterator, Traversable $otherIterator ) : Pinq\Iterators\IWrapperIterator
$iterator Traversable
$otherIterator Traversable
return Pinq\Iterators\IWrapperIterator

filterIterator() public method

Returns an iterator which will filter the elements according to the supplied predicate function.
public filterIterator ( Traversable $iterator, callable $predicate ) : Pinq\Iterators\IWrapperIterator
$iterator Traversable
$predicate callable
return Pinq\Iterators\IWrapperIterator

flattenedIterator() public method

Returns an iterator which will iterate each element of the inner iterator's values. An exception will be thrown if an invalid iterator is returned from the supplied iterator.
public flattenedIterator ( Traversable $iterator ) : Pinq\Iterators\IWrapperIterator
$iterator Traversable
return Pinq\Iterators\IWrapperIterator

groupJoinIterator() public method

Returns an iterator which will return the outer elements joined to the inner elements. All matched inner elements for each outer element will be wrapped in a traversable implementation from the supplied factory.
public groupJoinIterator ( Traversable $outerIterator, Traversable $innerIterator, callable $traversableFactory ) : Pinq\Iterators\IJoinIterator
$outerIterator Traversable
$innerIterator Traversable
$traversableFactory callable
return Pinq\Iterators\IJoinIterator

groupedIterator() public method

Returns an iterator which will group the elements according to the supplied function and wrap each group in a traversable implementation from the supplied factory.
public groupedIterator ( Traversable $iterator, callable $groupKeyFunction, callable $traversableFactory ) : Pinq\Iterators\IWrapperIterator
$iterator Traversable
$groupKeyFunction callable
$traversableFactory callable
return Pinq\Iterators\IWrapperIterator

intersectionIterator() public method

Returns an iterator which will return unique values present in the first and second iterator.
public intersectionIterator ( Traversable $iterator, Traversable $otherIterator ) : Pinq\Iterators\IWrapperIterator
$iterator Traversable
$otherIterator Traversable
return Pinq\Iterators\IWrapperIterator

joinIterator() public method

Returns an iterator which will return the outer elements joined to the inner elements.
public joinIterator ( Traversable $outerIterator, Traversable $innerIterator ) : Pinq\Iterators\IJoinIterator
$outerIterator Traversable
$innerIterator Traversable
return Pinq\Iterators\IJoinIterator

orderedIterator() public method

Returns an iterator with will sort the elements according to the supplied function and direction.
public orderedIterator ( Traversable $iterator, callable $function, boolean $isAscending ) : Pinq\Iterators\IOrderedIterator
$iterator Traversable
$function callable
$isAscending boolean
return Pinq\Iterators\IOrderedIterator

projectionIterator() public method

Returns an iterator which will return the elements mapped by the supplied functions or the original if no function is supplied.
public projectionIterator ( Traversable $iterator, callable $keyProjectionFunction = null, callable $valueProjectionFunction = null ) : Pinq\Iterators\IWrapperIterator
$iterator Traversable
$keyProjectionFunction callable
$valueProjectionFunction callable
return Pinq\Iterators\IWrapperIterator

rangeIterator() public method

Returns an iterator which will only iterate the elements in the supplied range.
public rangeIterator ( Traversable $iterator, integer $start, integer | null $amount ) : Pinq\Iterators\IWrapperIterator
$iterator Traversable
$start integer
$amount integer | null
return Pinq\Iterators\IWrapperIterator

reindexerIterator() public method

Returns an iterator which will return the map the keys to 0-based incrementing integers
public reindexerIterator ( Traversable $iterator ) : Pinq\Iterators\IWrapperIterator
$iterator Traversable
return Pinq\Iterators\IWrapperIterator

toArray() public method

Non integer or string keys will be reindexed to respective incremented integers.
public toArray ( Traversable $iterator ) : array
$iterator Traversable
return array

toIterator() public method

Returns the supplied traversable or array as an iterator compatible with this scheme.
public toIterator ( Traversable | array $traversableOrArray ) : Traversable
$traversableOrArray Traversable | array
return Traversable

unionIterator() public method

Returns an iterator which will return unique values present in the first or second iterator.
public unionIterator ( Traversable $iterator, Traversable $otherIterator ) : Pinq\Iterators\IWrapperIterator
$iterator Traversable
$otherIterator Traversable
return Pinq\Iterators\IWrapperIterator

uniqueIterator() public method

Returns an iterator which will return unique values using strict equality.
public uniqueIterator ( Traversable $iterator ) : Pinq\Iterators\IWrapperIterator
$iterator Traversable
return Pinq\Iterators\IWrapperIterator

uniqueKeyIterator() public method

Returns an iterator which will return only the first associated value for any key.
public uniqueKeyIterator ( Traversable $iterator ) : Pinq\Iterators\IWrapperIterator
$iterator Traversable
return Pinq\Iterators\IWrapperIterator

walk() public method

Iterate over the keys and values of the supplied iterator and passes them (value, key) to the supplied function.
public walk ( Traversable $iterator, callable $function ) : void
$iterator Traversable
$function callable
return void

whereInIterator() public method

Returns an iterator which will return all values in the first iterator present in the second.
public whereInIterator ( Traversable $iterator, Traversable $otherIterator ) : Pinq\Iterators\IWrapperIterator
$iterator Traversable
$otherIterator Traversable
return Pinq\Iterators\IWrapperIterator