max element in vector
is it possible to use the stl MAX_ELEMENT algorithm to find the max value in a vector of vectors.
Say I have the following 5 x 3 matrix represented in a vec. of vec.
1 4 5
3 5 8
2 9 5
8 0 2
3 4 7
where each row is a vector, so we have 5 vectors within a vector.
I want to find the MAX_ELEMENT along the 1st, 2nd or 3rd column.
For the 1st one the result is 8, the 2nd is 9, the 3rd is 8.
Well, iterate over each column and apply max_element.
You'd have to define a custom iterator which iterates through each row. It would be a lot less work to just forego the max_element algorithm alltogether.
Not if you use a Boost iterator adaptor and a Lambda object. Then it becomes a matter of 10 minutes, if you have to look up the documentation.