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
24class DoubleIntRange final {
25 public:
26 class Iterator final {
27 private:
28 int i;
29 int j;
30 int j_max;
31
32 public:
33 Iterator(int i, int j, int j_max) : i(i), j(j), j_max(j_max) {}
34
35 std::tuple<int, int> operator*() const { return std::make_tuple(i, j); }
36
37 Iterator& operator++() {
38 ++j;
39
40 if (j == j_max) {
41 ++i;
42 j = 0;
43 }
44
45 return *this;
46 }
47
48 bool operator!=(const Iterator& other) const {
49 return i != other.i || j != other.j;
50 }
51 };
52
53 DoubleIntRange(const int i_max, const int j_max)
54 : i_max_(i_max), j_max_(j_max) {}
55
56 Iterator begin() const { return Iterator(0, 0, j_max_); }
57
58 Iterator end() const { return Iterator(i_max_, 0, j_max_); }
59
60 private:
61 int i_max_;
62 int j_max_;
63};
64
65} // namespace designlab
66
67#endif // DESIGNLAB_LOOP_UTIL_H_
constexpr VECTOR operator*(const VECTOR &vec, const float s)
Definition dxlib_util.h:120
constexpr bool operator!=(const unexpected< E > &lhs, const unexpected< E > &rhs)