dune-pdelab  2.4-dev
range.hh
Go to the documentation of this file.
1 // -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=8 sw=2 sts=2:
3 
4 #ifndef DUNE_PDELAB_COMMON_RANGE_HH
5 #define DUNE_PDELAB_COMMON_RANGE_HH
6 
7 #include<vector>
8 
9 namespace Dune {
10  namespace PDELab {
11 
13 
21  template<class T>
22  std::vector<T> rangeVector(T begin, T passed_the_end, T increment = 1) {
23  std::vector<T> tmp;
24  tmp.reserve((passed_the_end-begin)/increment);
25  for(T i = begin; i < passed_the_end; i+=increment)
26  tmp.push_back(i);
27  return tmp;
28  }
29 
31 
34  template<class T>
35  std::vector<T> rangeVector(T passed_the_end)
36  { return rangeVector(T(0), passed_the_end); }
37 
38  } // namespace PDELab
39 } // namespace Dune
40 
41 #endif // DUNE_PDELAB_COMMON_RANGE_HH
Definition: adaptivity.hh:27
std::vector< T > rangeVector(T begin, T passed_the_end, T increment=1)
Generate a vector with a range of numbers.
Definition: range.hh:22