Sunday, June 29, 2008

Iterators and Iterator Types

C++ Primer 4/e 3.4. Introducing Iterators ther is a terminology:『When first encountered, the nomenclature around iterators can be confusing. In part the confusion arises because the same term, iterator, is used to refer to two things. We speak generally of the concept of an iterator, and we speak specifically of a concrete iterator type defined by a container, such as vector.
What’s important to understand is that there is a collection of types that serve as iterators. These types are related conceptually. We refer to a type as an iterator if it supports a certain set of actions. Those actions let us navigate among the elements of a container and let us access the value of those elements.
Each container class defines its own iterator type that can be used to access the elements in the container. That is, each container defines a type named iterator, and that type supports the actions of an (conceptual) iterator.』
Chinese translationis said:『第一次遭遇術語iterators時可能會感到困惑。部份原因是同一個術語iterator可用來指兩件事。可以指一般的iterator概念,也可以指某容器(例如vector)所定義的具象iterator型別。
一件必須瞭解的重要事情是,有一大群型別可作為iterators使用。這些型別在概念上彼此關聯。當一個型別支援某「特定動作集」時我們稱它為iterator;它讓我們得以尋訪容器元素並存取元素值。
每個做為容器的class都定義有自己的iterator型別,可用來存取容器元素。也就是說每個容器都定意有一個名為iterator的型別,該型別支援(概念上的)iterator所能採取的動作。』
What is concrete ?I don't understand.

achi's Blog

No comments: