GaitGeneration by Graph Search
読み取り中…
検索中…
一致する文字列を見つけられません
loop_util.h
[詳解]
1
3
4// Copyright(c) 2023-2025 Design Engineering Laboratory, Saitama University
5// Released under the MIT license
6// https://opensource.org/licenses/mit-license.php
7
8#ifndef DESIGNLAB_LOOP_UTIL_H_
9#define DESIGNLAB_LOOP_UTIL_H_
10
11#include <tuple>
12
13namespace designlab
14{
15
25class DoubleIntRange final
26{
27public:
28 class Iterator final
29 {
30 private:
31 int i;
32 int j;
33 int j_max;
34
35 public:
36 Iterator(int i, int j, int j_max) : i(i), j(j), j_max(j_max) {}
37
38 std::tuple<int, int> operator*() const
39 {
40 return std::make_tuple(i, j);
41 }
42
43 Iterator& operator++()
44 {
45 ++j;
46
47 if (j == j_max)
48 {
49 ++i;
50 j = 0;
51 }
52
53 return *this;
54 }
55
56 bool operator!=(const Iterator& other) const
57 {
58 return i != other.i || j != other.j;
59 }
60 };
61
62 DoubleIntRange(const int i_max, const int j_max) :
63 i_max_(i_max),
64 j_max_(j_max)
65 {
66 }
67
68
69 Iterator begin() const
70 {
71 return Iterator(0, 0, j_max_);
72 }
73
74 Iterator end() const
75 {
76 return Iterator(i_max_, 0, j_max_);
77 }
78
79private:
80 int i_max_;
81 int j_max_;
82};
83
84} // namespace designlab
85
86#endif // DESIGNLAB_LOOP_UTIL_H_
constexpr VECTOR operator*(const VECTOR &vec, const float s)
Definition dxlib_util.h:120