27 #ifndef MLN_UTIL_INTERNAL_GRAPH_NBH_ITER_HH
28 # define MLN_UTIL_INTERNAL_GRAPH_NBH_ITER_HH
30 # include <mln/core/concept/proxy.hh>
31 # include <mln/util/internal/graph_nbh_iter_base.hh>
32 # include <mln/util/vertex.hh>
33 # include <mln/util/edge.hh>
50 class vertex_nbh_vertex_fwd_iterator
51 :
public nbh_iterator_base<G,
54 vertex_nbh_vertex_fwd_iterator<G> >
56 typedef util::vertex<G> V;
57 typedef vertex_nbh_vertex_fwd_iterator<G> self_;
58 typedef nbh_iterator_base<G, V, V, self_> super_;
68 vertex_nbh_vertex_fwd_iterator();
70 vertex_nbh_vertex_fwd_iterator(
const C& c);
77 bool is_valid_()
const;
81 unsigned start_id_()
const;
84 unsigned next_id_()
const;
88 friend class nbh_iterator_base<G, V, V, self_>;
92 class vertex_nbh_vertex_bkd_iterator
93 :
public nbh_iterator_base<G,
96 vertex_nbh_vertex_bkd_iterator<G> >
98 typedef util::vertex<G> V;
100 typedef vertex_nbh_vertex_bkd_iterator<G> self_;
101 typedef nbh_iterator_base<G, V, V, self_> super_;
111 vertex_nbh_vertex_bkd_iterator();
112 template <
typename C>
113 vertex_nbh_vertex_bkd_iterator(
const C& c);
120 bool is_valid_()
const;
124 unsigned start_id_()
const;
127 unsigned next_id_()
const;
131 friend class nbh_iterator_base<G, V, V, self_>;
139 template <
typename G>
140 class vertex_nbh_edge_fwd_iterator
141 :
public nbh_iterator_base<G,
144 vertex_nbh_edge_fwd_iterator<G> >
146 typedef util::vertex<G> V;
147 typedef util::edge<G> E;
148 typedef vertex_nbh_edge_fwd_iterator<G> self_;
149 typedef nbh_iterator_base<G, V, E, self_> super_;
159 vertex_nbh_edge_fwd_iterator();
160 template <
typename C>
161 vertex_nbh_edge_fwd_iterator(
const C& c);
168 bool is_valid_()
const;
172 unsigned start_id_()
const;
175 unsigned next_id_()
const;
179 friend class nbh_iterator_base<G, V, E, self_>;
183 template <
typename G>
184 class vertex_nbh_edge_bkd_iterator
185 :
public nbh_iterator_base<G,
188 vertex_nbh_edge_bkd_iterator<G> >
190 typedef util::vertex<G> V;
191 typedef util::edge<G> E;
192 typedef vertex_nbh_edge_bkd_iterator<G> self_;
193 typedef nbh_iterator_base<G, V, E, self_> super_;
203 vertex_nbh_edge_bkd_iterator();
204 template <
typename C>
205 vertex_nbh_edge_bkd_iterator(
const C& c);
212 bool is_valid_()
const;
216 unsigned start_id_()
const;
219 unsigned next_id_()
const;
223 friend class nbh_iterator_base<G, V, E, self_>;
231 template <
typename G>
232 class edge_nbh_edge_fwd_iterator
233 :
public nbh_iterator_base<G,
236 edge_nbh_edge_fwd_iterator<G> >
238 typedef util::edge<G> E;
239 typedef edge_nbh_edge_fwd_iterator<G> self_;
240 typedef nbh_iterator_base<G, E, E, self_> super_;
251 edge_nbh_edge_fwd_iterator();
252 template <
typename C>
253 edge_nbh_edge_fwd_iterator(
const C& c);
260 bool is_valid_()
const;
264 unsigned start_id_()
const;
267 unsigned next_id_()
const;
271 friend class nbh_iterator_base<G, E, E, self_>;
275 template <
typename G>
276 class edge_nbh_edge_bkd_iterator
277 :
public nbh_iterator_base<G,
280 edge_nbh_edge_bkd_iterator<G> >
282 typedef util::edge<G> E;
284 typedef edge_nbh_edge_bkd_iterator<G> self_;
285 typedef nbh_iterator_base<G, E, E, self_> super_;
296 edge_nbh_edge_bkd_iterator();
297 template <
typename C>
298 edge_nbh_edge_bkd_iterator(
const C& c);
305 bool is_valid_()
const;
309 unsigned start_id_()
const;
312 unsigned next_id_()
const;
316 friend class nbh_iterator_base<G, E, E, self_>;
319 # ifndef MLN_INCLUDE_ONLY
325 template <
typename G>
327 vertex_nbh_vertex_fwd_iterator<G>::vertex_nbh_vertex_fwd_iterator()
331 template <
typename G>
332 template <
typename C>
334 vertex_nbh_vertex_fwd_iterator<G>::vertex_nbh_vertex_fwd_iterator(
const C& c)
339 template <
typename G>
342 vertex_nbh_vertex_fwd_iterator<G>::is_valid_()
const
344 return this->c_->is_valid() && this->i_ < this->c_->nmax_nbh_vertices();
347 template <
typename G>
350 vertex_nbh_vertex_fwd_iterator<G>::start_id_()
const
355 template <
typename G>
358 vertex_nbh_vertex_fwd_iterator<G>::next_id_()
const
363 template <
typename G>
366 vertex_nbh_vertex_fwd_iterator<G>::update_()
368 this->elt_.update_id(this->c_->ith_nbh_vertex(this->i_));
375 template <
typename G>
377 vertex_nbh_vertex_bkd_iterator<G>::vertex_nbh_vertex_bkd_iterator()
381 template <
typename G>
382 template <
typename C>
384 vertex_nbh_vertex_bkd_iterator<G>::vertex_nbh_vertex_bkd_iterator(
const C& c)
389 template <
typename G>
392 vertex_nbh_vertex_bkd_iterator<G>::is_valid_()
const
394 return this->c_->is_valid() && this->i_ < this->c_->nmax_nbh_vertices();
397 template <
typename G>
400 vertex_nbh_vertex_bkd_iterator<G>::start_id_()
const
402 return this->c_->nmax_nbh_vertices() - 1;
405 template <
typename G>
408 vertex_nbh_vertex_bkd_iterator<G>::next_id_()
const
413 template <
typename G>
416 vertex_nbh_vertex_bkd_iterator<G>::update_()
418 this->elt_.update_id(this->c_->ith_nbh_vertex(this->i_));
426 template <
typename G>
428 vertex_nbh_edge_fwd_iterator<G>::vertex_nbh_edge_fwd_iterator()
432 template <
typename G>
433 template <
typename C>
435 vertex_nbh_edge_fwd_iterator<G>::vertex_nbh_edge_fwd_iterator(
const C& c)
440 template <
typename G>
443 vertex_nbh_edge_fwd_iterator<G>::is_valid_()
const
445 return this->c_->is_valid() && this->i_ < this->c_->nmax_nbh_edges();
448 template <
typename G>
451 vertex_nbh_edge_fwd_iterator<G>::start_id_()
const
456 template <
typename G>
459 vertex_nbh_edge_fwd_iterator<G>::next_id_()
const
464 template <
typename G>
467 vertex_nbh_edge_fwd_iterator<G>::update_()
469 this->elt_.update_id(this->c_->ith_nbh_edge(this->i_));
476 template <
typename G>
478 vertex_nbh_edge_bkd_iterator<G>::vertex_nbh_edge_bkd_iterator()
482 template <
typename G>
483 template <
typename C>
485 vertex_nbh_edge_bkd_iterator<G>::vertex_nbh_edge_bkd_iterator(
const C& c)
490 template <
typename G>
493 vertex_nbh_edge_bkd_iterator<G>::is_valid_()
const
495 return this->c_->is_valid() && this->i_ < this->c_->nmax_nbh_edges();
498 template <
typename G>
501 vertex_nbh_edge_bkd_iterator<G>::start_id_()
const
503 return this->c_->nmax_nbh_edges() - 1;
506 template <
typename G>
509 vertex_nbh_edge_bkd_iterator<G>::next_id_()
const
514 template <
typename G>
517 vertex_nbh_edge_bkd_iterator<G>::update_()
519 this->elt_.update_id(this->c_->ith_nbh_edge(this->i_));
528 template <
typename G>
530 edge_nbh_edge_fwd_iterator<G>::edge_nbh_edge_fwd_iterator()
534 template <
typename G>
535 template <
typename C>
537 edge_nbh_edge_fwd_iterator<G>::edge_nbh_edge_fwd_iterator(
const C& c)
542 template <
typename G>
545 edge_nbh_edge_fwd_iterator<G>::is_valid_()
const
547 return this->c_->is_valid() && this->i_ < this->c_->nmax_nbh_edges();
550 template <
typename G>
553 edge_nbh_edge_fwd_iterator<G>::start_id_()
const
558 template <
typename G>
561 edge_nbh_edge_fwd_iterator<G>::next_id_()
const
566 template <
typename G>
569 edge_nbh_edge_fwd_iterator<G>::update_()
575 util::edge_id_t e_id = this->c_->ith_nbh_edge(this->i_);
576 while (e_id == this->c_->id())
578 this->i_ = next_id_();
579 e_id = this->c_->ith_nbh_edge(this->i_);
582 this->elt_.update_id(e_id);
589 template <
typename G>
591 edge_nbh_edge_bkd_iterator<G>::edge_nbh_edge_bkd_iterator()
595 template <
typename G>
596 template <
typename C>
598 edge_nbh_edge_bkd_iterator<G>::edge_nbh_edge_bkd_iterator(
const C& c)
603 template <
typename G>
606 edge_nbh_edge_bkd_iterator<G>::is_valid_()
const
608 return this->c_->is_valid() && this->i_ < this->c_->nmax_nbh_edges();
611 template <
typename G>
614 edge_nbh_edge_bkd_iterator<G>::start_id_()
const
616 return this->c_->nmax_nbh_edges() - 1;
619 template <
typename G>
622 edge_nbh_edge_bkd_iterator<G>::next_id_()
const
627 template <
typename G>
630 edge_nbh_edge_bkd_iterator<G>::update_()
635 unsigned e_id = this->c_->ith_nbh_edge(this->i_);
636 while (e_id == this->c_->id())
638 this->i_ = next_id_();
639 e_id = this->c_->ith_nbh_edge(this->i_);
642 this->elt_.update_id(e_id);
645 # endif // !MLN_INCLUDE_ONLY
652 #endif // ! MLN_UTIL_INTERNAL_GRAPH_NBH_ITER_HH