Skeleton_blockers_blockers_iterators.h
1 /* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
2  * See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
3  * Author(s): David Salinas
4  *
5  * Copyright (C) 2014 Inria
6  *
7  * Modification(s):
8  * - YYYY/MM Author: Description of the modification
9  */
10 
11 #ifndef SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_BLOCKERS_ITERATORS_H_
12 #define SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_BLOCKERS_ITERATORS_H_
13 
14 #include <boost/iterator/iterator_facade.hpp>
15 
16 namespace Gudhi {
17 
18 namespace skeleton_blocker {
19 
23 // ReturnType = const Simplex* or Simplex*
24 // MapIteratorType = BlockerMapConstIterator or BlockerMapIterator
25 
26 template<typename MapIteratorType, typename ReturnType>
27 class Blocker_iterator_internal : public boost::iterator_facade<
28 Blocker_iterator_internal<MapIteratorType, ReturnType>,
29 ReturnType,
30 boost::forward_traversal_tag,
31 ReturnType
32 > {
33  private:
34  MapIteratorType current_position;
35  MapIteratorType end_of_map;
36 
37  public:
38  Blocker_iterator_internal() : current_position() { }
39 
40  Blocker_iterator_internal(MapIteratorType position, MapIteratorType end_of_map_) :
41  current_position(position), end_of_map(end_of_map_) { }
42 
43  bool equal(const Blocker_iterator_internal& other) const {
44  return current_position == other.current_position;
45  }
46 
47  void increment() {
48  goto_next_blocker();
49  }
50 
51  ReturnType dereference() const {
52  return (current_position->second);
53  }
54 
55  private:
61  void goto_next_blocker() {
62  do {
63  ++current_position;
64  } while (!(current_position == end_of_map) && !first_time_blocker_is_seen());
65  }
66 
67  bool first_time_blocker_is_seen() const {
68  return current_position->first == current_position->second->first_vertex();
69  }
70 };
71 
75 // ReturnType = const Simplex* or Simplex*
76 // MapIteratorType = BlockerMapConstIterator or BlockerMapIterator
77 
78 template<typename MapIteratorType, typename ReturnType>
79 class Blocker_iterator_around_vertex_internal : public boost::iterator_facade<
80 Blocker_iterator_around_vertex_internal<MapIteratorType, ReturnType>,
81 ReturnType,
82 boost::forward_traversal_tag,
83 ReturnType
84 > {
85  private:
86  MapIteratorType current_position_;
87 
88  public:
89  Blocker_iterator_around_vertex_internal() : current_position_() { }
90 
91  Blocker_iterator_around_vertex_internal(MapIteratorType position) :
92  current_position_(position) { }
93 
95  this->current_position_ = other.current_position_;
96  return *this;
97  }
98 
99  bool equal(const Blocker_iterator_around_vertex_internal& other) const {
100  return current_position_ == other.current_position_;
101  }
102 
103  void increment() {
104  current_position_++;
105  }
106 
107  ReturnType dereference() const {
108  return (current_position_->second);
109  }
110 
111  MapIteratorType current_position() {
112  return this->current_position_;
113  }
114 };
115 
116 } // namespace skeleton_blocker
117 
118 namespace skbl = skeleton_blocker;
119 
120 } // namespace Gudhi
121 
122 #endif // SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_BLOCKERS_ITERATORS_H_
Iterator through the blockers of a vertex.
Definition: Skeleton_blockers_blockers_iterators.h:79
Iterator through the blockers of a vertex.
Definition: Skeleton_blockers_blockers_iterators.h:27
Definition: SimplicialComplexForAlpha.h:14
GUDHI  Version 3.1.1  - C++ library for Topological Data Analysis (TDA) and Higher Dimensional Geometry Understanding.  - Copyright : MIT Generated on Fri Feb 7 2020 16:35:36 for GUDHI by Doxygen 1.8.13