.. _Advanced_Example: Advanced Example ================ An example of a more advanced associative operation is to find the index where ``Foo(i)`` is minimized. A serial version might look like this: :: long SerialMinIndexFoo( const float a[], size_t n ) { float value_of_min = FLT_MAX; // FLT_MAX from long index_of_min = -1; for( size_t i=0; i& r ) { const float *a = my_a; for( size_t i=r.begin(); i!=r.end(); ++i ) { float value = Foo(a[i]); if( value index_of_min(-1) {}   void join( const SumFoo& y ) { if( y.value_of_min index_of_min(-1), {} }; Now ``SerialMinIndex`` can be rewritten using ``parallel_reduce`` as shown below: :: long ParallelMinIndexFoo( float a[], size_t n ) { MinIndexFoo mif(a); parallel_reduce(blocked_range(0,n), mif ); return mif.index_of_min; }