Pages

Wednesday, March 26, 2014

The Iterable interface



The Iterable<Tv> interface 
(HHVM >= 2.5)
Introduction 
Interface to create an an iterable object that will work with mechanisms like foreach (e.g., foreach($c as $v)).
Interface synopsis 
Iterable<Tv> extends IteratorAggregate<Tv> {
/* Methods */
abstract public Iterator<Tv> getIterator ( void )
abstract public array Iterable<TV>::toArray ( void )
abstract public array Iterable<TV>::toValuesArray ( void )
abstract public Vector<Tv> toVector ( void )
abstract public Vector<Tv> toImmVector ( void )
abstract public Set<Tv> toVector ( void )
abstract public Iterable<Tv> values ( void )
abstract public Iterable<Tv> lazy ( void )
abstract public Iterable<Tu> map<Tu> ( function(Tv): Tu $callback )
abstract public Iterable<Tv> filter ( function(Tv): bool $callback )
abstract public Iterable<Pair<Tv, Tu>> zip<Tu> ( Traversable<Tu> $iterable )
/* Inherited methods */
abstract public Iterator<Tv> IteratorAggregate<Tv>::getIterator ( void )
}
Table of Contents 
·         Iterable<Tv>::getIterator — Retrieve an external iterator
·         Iterable<TV>::toArray — Convert an iterable to an array
·         Iterable<TV>::toValuesArray — Convert an iterable to an array of the values of the iterable, keyed by integers.
·         Iterable<Tv>::toVector — Convert an iterable to a vector
·         Iterable<Tv>::toImmVector — Convert an iterable to an immutable vector
·         Iterable<Tv>::toSet — Convert an iterable to a set
·         Iterable<Tv>::values — Return an iterable of this iterable's values.
·         Iterable<Tv>::lazy — Return a lazy iterable based on this underlying iterable.
·         Iterable<Tv>::map<Tu> — Return an iterable based on the return results of calling a provided function on every value of this iterable.
·         Iterable<Tv>::filter — Return an iterable containing the values of this iterable that cause the provided function to return true.
·         Iterable<Tv>::zip<Tu> — Return an iterable that combines the elements of this iterable and another provided iterable, pair-wise.

Iterable<Tv>::getIterator
(HHVM >= 2.5)
Iterable<Tv>::getIterator  Retrieve an external iterator
Description 
abstract public Iterator<Tv> Iterable<Tv>::getIterator ( void )
Returns an external iterator.
Parameters 
This function has no parameters.
Return Values 
An instance of an object implementing Iterator<Tv>r.
Errors/Exceptions 
Throws an Exception on failure.

Iterable<TV>::toArray
(HHVM >= 2.5)
Iterable<TV>::toArray  Convert an iterable to an array
Description 
abstract public array Iterable<TV>::toArray ( void )
Converts an interable to an array.
Parameters 
This function has no parameters.
Return Values 
An array.
Errors/Exceptions 
Throws an Exception on failure.

Iterable<TV>::toValuesArray
(HHVM >= 2.5)
Iterable<TV>::toValuesArray  Convert an iterable to an array of the values of the iterable, keyed by integers.
Description 
abstract public array Iterable<TV>::toValuesArray ( void )
Converts an iterable to an array of the values of the iterable, keyed by integers.
Parameters 
This function has no parameters.
Return Values 
An array.
Errors/Exceptions 
Throws an Exception on failure.

Iterable<Tv>::toVector
(HHVM >= 2.5)
Iterable<Tv>::toVector  Convert an iterable to a vector
Description 
abstract public Vector<Tv> Iterable<Tv>::toVector ( void )
Converts an iterable to a vector.
Parameters 
This function has no parameters.
Return Values 
A Vector<Tv>
Errors/Exceptions 
Throws an Exception on failure.

Iterable<Tv>::toImmVector
(HHVM >= 2.5)
Iterable<Tv>::toImmVector  Convert an iterable to an immutable vector
Description 
abstract public Vector<Tv> Iterable<Tv>::toImmVector ( void )
Converts an iterable to an immutable vector.
Parameters 
This function has no parameters.
Return Values 
A ImmVector<Tv>
Errors/Exceptions 
Throws an Exception on failure.

Iterable<Tv>::toSet
(HHVM >= 2.5)
Iterable<Tv>::toSet  Convert an iterable to a set
Description 
abstract public Set<Tv> Iterable<Tv>::toVector ( void )
Converts an iterable to a set.
Parameters 
This function has no parameters.
Return Values 
A Set<Tv>
Errors/Exceptions 
Throws an Exception on failure.

Iterable<Tv>::values
(HHVM >= 2.5)
Iterable<Tv>::values  Return an iterable of this iterable's values.
Description 
abstract public Iterable<Tv> Iterable<Tv>::values ( void )
Returns an iterable of this iterable's values.
Parameters 
This function has no parameters.
Return Values 
An Iterable<Tv>.
Errors/Exceptions 
Throws an Exception on failure.

Iterable<Tv>::lazy
(HHVM >= 2.5)
Iterable<Tv>::lazy  Return a lazy iterable based on this underlying iterable.
Description 
abstract public Iterable<Tv> Iterable<Tv>::lazy ( void )
Returns a lazy iterable based on this underlying iterable. Any change to the underlying iterable will be reflected in the returned lazy iterable.
Parameters 
This function has no parameters.
Return Values 
An Iterable<Tv>.
Errors/Exceptions 
Throws an Exception on failure.

Iterable<Tv>::map<Tu>
(HHVM >= 2.5)
Iterable<Tv>::map<Tu>  Return an iterable based on the return results of calling a provided function on every value of this iterable.
Description 
abstract public Iterable<Tu> Iterable<Tv>::map<Tu> ( function(Tv): Tu $callback )
Returns an iterable based on the return results of calling a provided function on every value of this iterable.
Parameters 
callback
The function callback to map to this iterable.
Return Values 
An Iterable<Tv>.
Errors/Exceptions 
Throws an Exception on failure.


Iterable<Tv>::filter
(HHVM >= 2.5)
Iterable<Tv>::filter  Return an iterable containing the values of this iterable that cause the provided function to return true.
Description 
abstract public Iterable<Tv> Iterable<Tv>::filter ( function(Tv): bool $callback )
Returns an iterable containing the values of this iterable that cause the provided function to return true.
Parameters 
callback
The function callback that filters this iterable.
Return Values 
An Iterable<Tv>.
Errors/Exceptions 
Throws an Exception on failure.

Iterable<Tv>::zip<Tu>
(HHVM >= 2.5)
Iterable<Tv>::zip<Tu>  Return an iterable that combines the elements of this iterable and another provided iterable, pair-wise.
Description 
abstract public Iterable<Pair<Tv, Tu>> Iterable<Tv>::zip<Tu> ( Traversable<Tu> $iterable)
Returns an iterable that combines the elements of this iterable and another provided iterable, pair-wise.
Parameters 
iterable
The iterable with the elements to combine with the elements of this iterable.
Return Values 
An Iterable<Tv>.
Errors/Exceptions 
Throws an Exception on failure.

No comments:

Post a Comment