3 #include <c10/util/Exception.h> 30 static constexpr
int kNextDirection = 0;
31 static constexpr
int kPrevDirection = 1;
58 T* operator*()
const {
61 T* operator->()
const {
66 cur = cur->next_in_graph[d];
76 cur = cur->next_in_graph[reverseDir()];
89 void destroyCurrent() {
91 cur = cur->next_in_graph[reverseDir()];
100 return d == kNextDirection ? kPrevDirection : kNextDirection;
106 template <
typename T>
123 return reverse().begin();
126 return reverse().begin();
129 return reverse().end();
132 return reverse().end();
136 head, d == kNextDirection ? kPrevDirection : kNextDirection);
140 head, d == kNextDirection ? kPrevDirection : kNextDirection);
143 return head->next_in_graph[d];
145 const T* front()
const {
146 return head->next_in_graph[d];
149 return head->next_in_graph[!d];
151 const T* back()
const {
152 return head->next_in_graph[!d];
161 template <
typename T>
162 static inline bool operator==(
168 template <
typename T>
169 static inline bool operator!=(
180 template <
typename T>
181 struct iterator_traits<
torch::jit::generic_graph_node_list_iterator<T>> {
182 using difference_type = int64_t;
186 using iterator_category = bidirectional_iterator_tag;