Typically parallel data abstractions are built around arrays or collection
types. Since multiple processors and address spaces may be involved,
the abstractions are for their distribution, access, and update across
memory and processor spaces.
Iterators provide a way to traverse aggregate data types and
to reference and update particular elements.
STL algorithms work using iterators (instead of
working on containers directly), iterators
are provided by containers, and
containers are template classes. Just as containers are
instantiated on regular C++ data types, they can be instantiated on future type
instantiations. Because iterator traversal and access operators do not
assume anything about the data type contained in the containers, the
same programs that work for containers of basic data types can work
for containers of future data types. Asynchronous and delayed computations come
for free, as values are not required until the point where the
dereferencing *
iterator operator is used to access the value of the base type. When
the result type of the use of the * operator resolves into a base
type, future resolution takes place. Thus sequential STL applications
can be easily adapted to future-based parallel applications.
Future-based iterators and containers can be assigned, copied, and
passed as arguments to the point where their values are accessed. This
allows us to write programs where delayed evaluations can be exploited
across procedure boundaries.