MinLCA algorithms
utils.hh
Go to the documentation of this file.
1 #ifndef __MINLCA_UTILS_UTILS_HH
2 #define __MINLCA_UTILS_UTILS_HH
3 #include <vector>
4 #include <algorithm>
5 #include <iterator>
6 
9 
10 namespace minlca
11 {
12 
17 namespace utils
18 {
19 
24 template<typename T>
25 inline int posMax(const std::vector<T> &v)
26 {
27  return std::distance(v.begin(), std::max_element(v.begin(), v.end()));
28 }
29 
33 inline std::vector<int> nonNegative(const std::vector<int> &v)
34 {
35  int n = v.size();
36  std::vector<int> result;
37 
38  for (int i = 0; i < n; ++i)
39  if (v[i] >= 0) {
40  result.push_back(i);
41  }
42 
43  return result;
44 }
45 }
46 }
47 
48 #endif
std::vector< int > nonNegative(const std::vector< int > &v)
Vector of non-negative indices.
Definition: utils.hh:33
Default namespace Default namespace for MinLCA algorithms.
Definition: base.hh:15
int posMax(const std::vector< T > &v)
Index of the maximum position.
Definition: utils.hh:25