Skip to content

Commit d7cba6f

Browse files
committed
out_edge
1 parent bf5232f commit d7cba6f

1 file changed

Lines changed: 27 additions & 28 deletions

File tree

include/osp/graph_algorithms/directed_graph_edge_view.hpp

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class edge_view {
136136
return *this;
137137
}
138138

139-
[[nodiscard]] DirectedEdgeIterator operator++(int) {
139+
DirectedEdgeIterator operator++(int) {
140140
DirectedEdgeIterator temp = *this;
141141
++(*this);
142142
return temp;
@@ -180,11 +180,11 @@ class out_edge_view {
180180
private:
181181
static_assert(is_directed_graph_v<Graph_t>, "Graph_t must satisfy the directed_graph concept");
182182

183-
const Graph_t &graph;
184-
vertex_idx_t<Graph_t> source_vertex;
183+
const Graph_t &graph_;
184+
vertex_idx_t<Graph_t> sourceVertex_;
185185

186186
template<typename child_iterator_t>
187-
class out_edge_iterator {
187+
class OutEdgeIterator {
188188
public:
189189
using iterator_category = typename std::iterator_traits<child_iterator_t>::iterator_category;
190190
using difference_type = std::ptrdiff_t;
@@ -198,60 +198,59 @@ class out_edge_view {
198198
};
199199

200200
private:
201-
vertex_idx_t<Graph_t> source_vertex;
202-
child_iterator_t current_child_it;
201+
vertex_idx_t<Graph_t> sourceVertex_;
202+
child_iterator_t currentChildIt_;
203203

204204
public:
205-
out_edge_iterator() = default;
206-
out_edge_iterator(vertex_idx_t<Graph_t> u, child_iterator_t it) : source_vertex(u), current_child_it(it) {}
205+
OutEdgeIterator() = default;
206+
OutEdgeIterator(vertex_idx_t<Graph_t> u, child_iterator_t it) : sourceVertex_(u), currentChildIt_(it) {}
207207

208-
[[nodiscard]] value_type operator*() const { return {source_vertex, *current_child_it}; }
208+
[[nodiscard]] value_type operator*() const { return {sourceVertex_, *currentChildIt_}; }
209209
[[nodiscard]] arrow_proxy operator->() const { return {operator*()}; }
210210

211-
out_edge_iterator &operator++() {
212-
++current_child_it;
211+
OutEdgeIterator &operator++() {
212+
++currentChildIt_;
213213
return *this;
214214
}
215215

216-
out_edge_iterator operator++(int) {
217-
out_edge_iterator temp = *this;
216+
OutEdgeIterator operator++(int) {
217+
OutEdgeIterator temp = *this;
218218
++(*this);
219219
return temp;
220220
}
221221

222-
out_edge_iterator &operator--() {
223-
--current_child_it;
222+
OutEdgeIterator &operator--() {
223+
--currentChildIt_;
224224
return *this;
225225
}
226226

227-
out_edge_iterator operator--(int) {
228-
out_edge_iterator temp = *this;
227+
OutEdgeIterator operator--(int) {
228+
OutEdgeIterator temp = *this;
229229
--(*this);
230230
return temp;
231231
}
232232

233-
[[nodiscard]] bool operator==(const out_edge_iterator &other) const noexcept {
234-
return current_child_it == other.current_child_it;
233+
[[nodiscard]] bool operator==(const OutEdgeIterator &other) const noexcept {
234+
return currentChildIt_ == other.currentChildIt_;
235235
}
236236

237-
[[nodiscard]] bool operator!=(const out_edge_iterator &other) const noexcept { return !(*this == other); }
237+
[[nodiscard]] bool operator!=(const OutEdgeIterator &other) const noexcept { return !(*this == other); }
238238
};
239239

240240
public:
241-
using iterator =
242-
out_edge_iterator<decltype(std::declval<Graph_t>().children(std::declval<vertex_idx_t<Graph_t>>()).begin())>;
243-
using const_iterator = iterator;
241+
using iterator = OutEdgeIterator<decltype(std::declval<Graph_t>().children(std::declval<vertex_idx_t<Graph_t>>()).begin())>;
242+
using constIterator = iterator;
244243

245-
out_edge_view(const Graph_t &graph_, vertex_idx_t<Graph_t> u) : graph(graph_), source_vertex(u) {}
244+
out_edge_view(const Graph_t &graph, vertex_idx_t<Graph_t> u) : graph_(graph), sourceVertex_(u) {}
246245

247-
[[nodiscard]] auto begin() const { return iterator(source_vertex, graph.children(source_vertex).begin()); }
246+
[[nodiscard]] auto begin() const { return iterator(sourceVertex_, graph_.children(sourceVertex_).begin()); }
248247
[[nodiscard]] auto cbegin() const { return begin(); }
249248

250-
[[nodiscard]] auto end() const { return iterator(source_vertex, graph.children(source_vertex).end()); }
249+
[[nodiscard]] auto end() const { return iterator(sourceVertex_, graph_.children(sourceVertex_).end()); }
251250
[[nodiscard]] auto cend() const { return end(); }
252251

253-
[[nodiscard]] auto size() const { return graph.out_degree(source_vertex); }
254-
[[nodiscard]] bool empty() const { return graph.out_degree(source_vertex) == 0; }
252+
[[nodiscard]] auto size() const { return graph_.out_degree(sourceVertex_); }
253+
[[nodiscard]] bool empty() const { return graph_.out_degree(sourceVertex_) == 0; }
255254
};
256255

257256
/**

0 commit comments

Comments
 (0)