What is the iterator?

Iterator is a computer language construct that allows the program to read a group of data values ​​or information systematically. The iterators also allow an individual approach to each group member without affecting the rest of the group. They are used in many languages ​​scripting and programming, including C ++, Java, PHP and Perl. Their implementation is independent of objects that scan, so they can scan any type of object group. In most computer languages, iterators are used to browse groups of related objects called collections. Their implementations are very flexible and can be used with collections of any size. In general, they are safer than a simple approach to the collection elements, as their extent is limited to elements in the collection. Although it is still possible to access the index outside the limit, it is unlikely whether it is the iterator is used correctly.

The iterators are defined, initialized and processed in memory differently depending on computerthe language in which they are used. On the contrary, the general syntax is similar in most languages. There are two different types of syntax that can be used for iterators defined as explicit or implicit.

Explicit iterators include the creation of an iterator object, and this object is then used in a traverse loop through the collection elements. Implicitive iterators include a special type of loop structure that creates an iterator object without being entered in advance. Whether they are for any particular traverse depends on the preference of the programmer is whether explicit or implicit iterators are used because differences in the amount of code or performance between them are negligible. The biggest difference between explicit and implicit iterators is to explain ICITs to create the creation of iterator in the source code, while implicit iterators do not show it.

whenever there is an object collectionIt can be used to scan them iterator. Depending on computer language abilities, iterators can be used on fields, maps, lists and many other types of collection. The iterators are a relatively ubiquitous feature of programming languages ​​and most common languages ​​have some type of functionality. Some computer languages ​​allow iterators with other features such as restrictions, how many times access to the element. Because these functions are not universal, sometimes there are ways to be implemented independently of the iterators themselves.

IN OTHER LANGUAGES

Was this article helpful? Thanks for the feedback Thanks for the feedback

How can we help? How can we help?