Template TEClass objects are not supported in pC++ version 1.0. This section is a preview for version 2.0.

The most direct approach to building a collection is to define
it as a *template TEClass*, where we supply the type of
the collection element as the first template parameter.
The template structure can be derived from a parent template TECLASS
which will provide the data structures to manage the set
of element on each processor thread according to the alignment and
distribution specifications. We call this data structure manager
collection the SuperKernel. The basic Template TEClass takes
the following form.

template<Class ElementType> TEClass C: SuperKernel<ElementType> { C(Distribution *D, Align *A, n, m): SuperKernel(D, A) { ... } ... int alpha(); };

Given an element class E defined by

class E{ public: float x, y; void f( int i); double g(); };

and a distribution D and alignment A, one can create a collection X of type C with element type E with a declaration of the form:

There are a number of different parallel operators that can be applied to the collection X. The simplest is the evaluation of TEClass member functions, such as alpha() in the collection C above, on each thread associated with the distribution. Because the collection is, at heart, a TEClass this is nothing new and the expressionC<E> X(&D, &A);

behaves exactly as described in the previous chapter.X.alpha();

However, with a collection there is another form of parallelism. Given a member function of element class, f(), one can apply the function to every element of the collection with the expression

Alternatively, one can index a subset of elements in a collection with the expressionX.f(1);

which will invoke the function f() on elements with index in the range from i to j with step size k. (For multi-dimensional collections, the array notation extends in the obvious manner, but this is not reliable in Version 1.0.)X[i:j:k].f()

It is also possible to cause an element member function to be invoked on a single element of a collection by using the SuperKernel overloaded operator (...).

Mon Nov 21 09:49:54 EST 1994