I l@ve RuBoard Previous Section Next Section

adjacent_find()

By default, looks for the first adjacent pair of duplicate elements. A binary operator can override the built-in equality operator. Returns an iterator that addresses the first element of the pair.



#include <algorithm> 


class TwiceOver { 


public: 


   bool operator() ( int val1, int val2 ) 


        { return val1 == val2/2 ? true : false; } 


}; 





piter = adjacent_find( ia, ia+8 ); 


iter  = adjacent_find( vec.begin(), vec.end(), TwiceOver() ); 
    I l@ve RuBoard Previous Section Next Section