Implementing linked list with iterator interface

烂漫一生 提交于 2019-12-06 13:27:10
Devendra D. Chavan

An iterator is simply a generalized term for something that allows you to traverse a container (like an array, list, etc).

From wikipedia,

In computer programming, an iterator is an object that enables a programmer to traverse a container. Various types of iterators are often provided via a container's interface. Though the interface and semantics of a given iterator are fixed, iterators are often implemented in terms of the structures underlying a container implementation and are often tightly coupled to the container to enable the operational semantics of the iterator. Note that an iterator performs traversal and also gives access to data elements in a container, but does not perform iteration (i.e., not without some significant liberty taken with that concept or with trivial use of the terminology). An iterator is behaviorally similar to a database cursor.

As your assignment talks about creating an iterator without access the elements directly, you can have a look at Iterator Design Pattern

More information on Iterator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!