11 #ifndef ACTIVE_WITNESS_ACTIVE_WITNESS_ITERATOR_H_
12 #define ACTIVE_WITNESS_ACTIVE_WITNESS_ITERATOR_H_
14 #include <boost/iterator/iterator_facade.hpp>
19 namespace witness_complex {
27 template<
typename Active_witness,
28 typename Id_distance_pair,
29 typename INS_iterator >
31 :
public boost::iterator_facade< Active_witness_iterator <Active_witness, Id_distance_pair, INS_iterator>,
32 Id_distance_pair const,
33 boost::forward_traversal_tag,
34 Id_distance_pair const> {
35 friend class boost::iterator_core_access;
37 typedef typename std::list<Id_distance_pair>::iterator Pair_iterator;
48 : aw_(aw), lh_(aw_->nearest_landmark_table_.end()), is_end_(
true) {
54 if (lh_ == aw_->nearest_landmark_table_.end()) {
55 if (aw_->iterator_next_ == aw_->iterator_end_) {
58 aw_->nearest_landmark_table_.push_back(*aw_->iterator_next_);
59 lh_ = --aw_->nearest_landmark_table_.end();
60 ++(aw_->iterator_next_);
66 Id_distance_pair& dereference()
const {
70 bool equal(
const Iterator& other)
const {
71 return (is_end_ == other.is_end_) || (lh_ == other.lh_);
76 GUDHI_CHECK(!is_end_ && lh_ != aw_->nearest_landmark_table_.end(),
77 std::logic_error(
"Wrong active witness increment."));
81 if (lh_ == aw_->nearest_landmark_table_.end()) {
82 if (aw_->iterator_next_ == aw_->iterator_end_) {
85 aw_->nearest_landmark_table_.push_back(*aw_->iterator_next_);
86 lh_ = std::prev(aw_->nearest_landmark_table_.end());
87 ++(aw_->iterator_next_);
Iterator in the nearest landmark list.
Definition: Active_witness_iterator.h:34
Class representing a list of nearest neighbors to a given witness.
Definition: Active_witness.h:27
Gudhi namespace.
Definition: SimplicialComplexForAlpha.h:14