-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetMaxElement.cpp
More file actions
40 lines (33 loc) · 799 Bytes
/
GetMaxElement.cpp
File metadata and controls
40 lines (33 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <algorithm>
#include <array>
#include <chrono>
#include <vector>
#include <cfloat>
#include "Headers/Global.hpp"
#include "Headers/GetMaxElement.hpp"
float get_max_element(const vector_1d& i_vector)
{
return *std::max_element(i_vector.begin(), i_vector.end());
}
float get_max_element(const vector_2d& i_vector)
{
float output = FLT_MIN;
for (const vector_1d& a : i_vector)
{
//We're using recursion! ---------
// |
// |
// \/
output = std::max(output, get_max_element(a));
}
return output;
}
float get_max_element(const vector_3d& i_vector)
{
float output = FLT_MIN;
for (const vector_2d& a : i_vector)
{
output = std::max(output, get_max_element(a));
}
return output;
}