|
|
template <class T>
const T* rt_pos(
const T& val,
const T* b,
const T* e
);
template <class T>
const T* rt_pos_p(
int (*pred)(const T*),
const T* b,
const T* e
);
template <class T>
const T* rt_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 rightmost element satisfying some criterion. If no such element can be found, they return 0.
template <class T>
const T* rt_pos(
const T& val,
const T* b,
const T* e
);
Uses equality with val as the criterion, with T::operator== used for equality.
template <class T>
const T* rt_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* rt_pos_r(
int (*rel)(const T*, const T),
const T& val,
const T* b,
const T* e
);
Like rt_pos except that rel is used for the equality test.
If N is the size of the array, then 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.