Method get_iterator()


Method get_iterator

Iterator get_iterator(object|array|mapping|multiset|string data, mixed ... args)

Description

Creates and returns a canonical iterator for data.

Returns
data can have any of the following types:
object

If data is an object with lfun::_get_iterator defined then it's called in it with the arguments args to create the iterator.

If data is an object that lacks lfun::_get_iterator then it's checked if it has lfun::_iterator_next() in which case it will simply be returned. Otherwise an attempt to wrap it in a CompatIterator will be performed.

array

If data is an array, an Array.Iterator object will be returned.

mapping

If data is a mapping, a Mapping.Iterator object will be returned

multiset

If data is a multiset, a Multiset.Iterator object will be returned

string

If data is a string, a String.Iterator object will be returned

Note

This function is used by foreach to get an iterator for an object.

See also

Iterator, lfun::_get_iterator