[Next] [Up] [Previous]
Next: Selections and Masked Operations Up: Group Topologies Previous: Group Topologies

Topology Classes

TACO's collective operations assume that the members of a group define an STL style iterator that (recursively) iterates all members of a collection (a so-called input iterator in the STL terminology). Following this convention, each topology class must at least define an iterator type and the begin() and end() methods, where begin() refers to the first element to be iterated and end() refers to the ''first invalid'' element.
template<class T>
class BinTree {
 public: 
typedef ObjectPtr<T>* iterator; BinTree() { slot = 0; } void join(ObjectPtr<T> obj) { ObjectPtr<T> NIL; if (child[slot] == NIL) child[slot] = obj; else child[slot]->apply( m2f(&join,obj) ); slot = (slot+1) % 2; } iterator begin() { return &child[0]; } iterator end() { return &child[2]; } int size() const { return 2; } protected: ObjectPtr<T> child[2]; int slot; };
The iterator effectively determines the order in which the specified functor is passed to the group members and must have the -> operator defined, in the case the iterator is not a C++ pointer type.

Most of TACO's topology classes also provide a join() method to add new members dynamically to the group. This is also a prerequisite to apply the GroupOf and CollectionOf classes to create entire collections with an a priori known size. Note, that the code to build the distributed tree recursively has nearly the same structure as the code for a local tree and distributed programs can be written with the same ease as local programs.


[Next] [Up] [Previous]
Next: Selections and Masked Operations Up: Group Topologies Previous: Group Topologies