template <class T> const T* pos(const T& val,const T* b,const T* e); template <class T> const T* pos_p(int (*pred)(const T*), const T* b,const T* e); template <class T> const T* pos_r( int (*rel)(const T*,const T*), const T& val, const T* b, const T* e );
(1) For the plain version, T::operator== defines an equivalence relation on T.
(2) For the relational version, rel defines an equivalence relation on T.
These functions return a pointer to the leftmost element satisfying some criterion. If no such element can be found, they return 0.
template <class T> const T* pos(const T& val,const T* b,const T* e);
Uses equality with val as the criterion, with T::operator== used for the equality test.
template <class T> const T* pos_p(int (*pred)(const T*,const T* b,const T* e);
Uses the predicate pred as the criterion. That is, if p is a pointer into the array, then *p satisfies the criterion if pred(p) is true.
template <class T> const T* pos_r( int (*rel)(const T*,const T*), const T& val, const T* b, const T* e );
Like pred, except that it uses rel for the equality test.
If N is the size of the array, complexity is O(N). At most N equality tests are done.
Because a Block (see Block(3C++)) can always be used wherever an array is called for, Array Algorithms can also be used with Blocks. In fact, these two components were actually designed to be used together.