-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVectors.h
44 lines (38 loc) · 1.26 KB
/
Vectors.h
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
41
42
43
44
//Vectors.h
#ifndef NEO_TOOLBOX_VECTORS_H
#define NEO_TOOLBOX_VECTORS_H
#include <vector>
namespace sdlUtility {
/// Functions used to operate on std::vector structures.
namespace Vectors {
/// Finds the maximum value within the specified vector and returns its index.
template <class Type>
int FindMaximum(std::vector<Type> Vector) {
unsigned int Size = Vector.size();
if (Size > 0) {
int Maximum = 0;
for (unsigned int i =0; i<Size; i++) {
if (Vector[i] > Vector[Maximum]) {
Maximum = i;
}
}
return Maximum;
} else return 0;
}
/// Finds the minimum value within the specified vector and returns its index.
template <class Type>
int FindMinimum(std::vector<Type> Vector) {
unsigned int Size = Vector.size();
if (Size > 0) {
int Minimum = 0;
for (unsigned int i =0; i<Size; i++) {
if (Vector[i] < Vector[Minimum]) {
Minimum = i;
}
}
return Minimum;
} else return 0;
}
}
}
#endif