STL Learning Notes (iterator type)

Source: Internet
Author: User

Iterator type

An iterator is an object that "can traverse all elements within a sequence." It can do its job through an interface that is consistent with the general pointer.

Different iterators have different "capabilities" (travel and access capabilities)

I nput iterators

The input iterator can only read elements one at a time, passing back the element values in this order.

Almost all iterators have the ability to input iterators and are usually stronger. A typical example of a purely input iterator is an iterator that reads data from a standard input device.

The following table lists the various operational behaviors of the input iterator

Output iterator

The output iterator, instead of the input iterator, works by writing element values one after the other.

The following table lists the various operational behaviors of the output iterator

Forward (forward) iterator

The forward iterator is a combination of the input iterator and the output iterator, with the full functionality of the input iterator and most of the functionality of the output iterator, which summarizes all the operations of the forward iterator

Bidirectional (bidirectional) iterator

The bidirectional iterator adds the ability to traverse backwards on the basis of the forward iterator. In other words, it supports the decrement operator for a step-by-step fallback operation

Random access (discretionary access) iterator

The random access iterator builds on the bidirectional iterator and adds the ability to randomly access the device. Therefore, it must provide an "iterator arithmetic operation" (to add and subtract an offset, to handle the distance problem).

The following is a list of new actions for the random access iterator

STL Learning Notes (iterator type)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.