|
|
template <class T> const T* minimum(const T* b,const T* e); template <class T> const T* minimum_r(int (*rel)(const T*, const T*), const T* b,const T* e);
(1) For the plain version, T::operator< defines a total ordering relation on T.
(2) For the relational version, rel defines a total ordering relation on T.
These functions return a pointer to the leftmost instance of the smallest element in the array. If the array is empty (b >= e), the value of e is returned as the function result.
template <class T> const T* minimum(const T* b,const T* e);
Uses T::operator< to find the smallest element.
template <class T> const T* minimum_r(int (*rel)(const T*,const T*), const T* b,const T* e);
Uses rel to find the smallest element.
If N is the size of the array, then complexity is O(N). Exactly N-1 tests of the ordering relation 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.