Design pattern----iterator (iterator) mode

Source: Internet
Author: User
Design Patterns ----iterator ( iterator )   Mode GoF   : provides a way to access each element of a Bureau and object sequentially without exposing the internal representation of the object. When we study the data structure, we will provide a variety of ways to traverse the linked list when we implement the linked list (list). For an aggregation object, such as Java ArrayList should also provide a way for others to access his elements without exposing his internal structure.   In addition, for different needs, you might want to traverse the table in different ways. As can be seen from the definition of GOF, iterators are generated for containers. Obviously, the access to a container (or) Collection object is designed to be a lot of traversal algorithms. In Java, the iterator pattern has been merged into collection, and as the JDK continues to escalate, the iterator pattern is becoming more and more powerful in the Java collection.   In the vast majority of cases, we do not need to create a iterator, as long as the object loaded into the collection, directly with the iterator to traverse it. This application is too much, in this chapter will not give examples, the following gives a structure diagram (from Gof "design mode")

trackback:http://tb.blog.csdn.net/trackback.aspx?postid=987332

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.