23 #ifndef ACTIVE_WITNESS_ACTIVE_WITNESS_ITERATOR_H_ 24 #define ACTIVE_WITNESS_ACTIVE_WITNESS_ITERATOR_H_ 26 #include <boost/iterator/iterator_facade.hpp> 31 namespace witness_complex {
39 template<
typename Active_witness,
40 typename Id_distance_pair,
41 typename INS_iterator >
42 class Active_witness_iterator
43 :
public boost::iterator_facade< Active_witness_iterator <Active_witness, Id_distance_pair, INS_iterator>,
44 Id_distance_pair const,
45 boost::forward_traversal_tag,
46 Id_distance_pair const> {
47 friend class boost::iterator_core_access;
49 typedef typename std::list<Id_distance_pair>::iterator Pair_iterator;
50 typedef typename Gudhi::witness_complex::Active_witness_iterator<Active_witness,
52 INS_iterator> Iterator;
59 Active_witness_iterator(Active_witness* aw)
60 : aw_(aw), lh_(aw_->nearest_landmark_table_.end()), is_end_(true) {
63 Active_witness_iterator(Active_witness* aw,
const Pair_iterator& lh)
66 if (lh_ == aw_->nearest_landmark_table_.end()) {
67 if (aw_->iterator_next_ == aw_->iterator_end_) {
70 aw_->nearest_landmark_table_.push_back(*aw_->iterator_next_);
71 lh_ = --aw_->nearest_landmark_table_.end();
72 ++(aw_->iterator_next_);
78 Id_distance_pair& dereference()
const {
82 bool equal(
const Iterator& other)
const {
83 return (is_end_ == other.is_end_) || (lh_ == other.lh_);
88 GUDHI_CHECK(!is_end_ && lh_ != aw_->nearest_landmark_table_.end(),
89 std::logic_error(
"Wrong active witness increment."));
93 if (lh_ == aw_->nearest_landmark_table_.end()) {
94 if (aw_->iterator_next_ == aw_->iterator_end_) {
97 aw_->nearest_landmark_table_.push_back(*aw_->iterator_next_);
98 lh_ = std::prev(aw_->nearest_landmark_table_.end());
99 ++(aw_->iterator_next_);
108 #endif // ACTIVE_WITNESS_ACTIVE_WITNESS_ITERATOR_H_ Definition: SimplicialComplexForAlpha.h:26