vdj_pipe
pipeline for processing DNA sequence data
id_iterator.hpp
Go to the documentation of this file.
1 
7 #ifndef ID_ITERATOR_HPP_
8 #define ID_ITERATOR_HPP_
9 #include "boost/iterator/iterator_facade.hpp"
10 #include "boost/range.hpp"
11 
12 namespace vdj_pipe{
13 
16 template<class Id> class Id_iterator
17  : public boost::iterator_facade<
18  Id_iterator<Id>, Id, boost::forward_traversal_tag, Id
19  > {
20 
21  friend class boost::iterator_core_access;
22 public:
24  Id_iterator() : id_() {}
25  Id_iterator(const Id id) : id_(id) {}
26 
27 private:
28  Id id_;
29  Id dereference() const {return id_;}
30  void increment() {++id_.val_;}
31  bool equal(self_type const& i) const {return i.id_ == id_;}
32  typename self_type::difference_type distance_to(self_type const& i) const {
33  return id_() - i.id_();
34  }
35 };
36 
39 template<class Id> inline boost::iterator_range<Id_iterator<Id> >
40 id_range(const Id id1, const Id id2) {
41  typedef Id_iterator<Id> iter_t;
42  return boost::iterator_range<Id_iterator<Id> >(iter_t(id1), iter_t(id2));
43 }
44 
45 }//namespace vdj_pipe
46 #endif /* ID_ITERATOR_HPP_ */
Id_iterator()
Definition: id_iterator.hpp:24
Id id_
Definition: id_iterator.hpp:28
Id dereference() const
Definition: id_iterator.hpp:29
bool equal(self_type const &i) const
Definition: id_iterator.hpp:31
self_type::difference_type distance_to(self_type const &i) const
Definition: id_iterator.hpp:32
Id_iterator(const Id id)
Definition: id_iterator.hpp:25
Id_iterator self_type
Definition: id_iterator.hpp:23
Main namespace of vdj_pipe library.
Definition: keywords_variable.hpp:11
const std::string id1
Definition: file_ostream_variant_run.cpp:21
boost::iterator_range< Id_iterator< Id > > id_range(const Id id1, const Id id2)
Definition: id_iterator.hpp:40
Definition: id_iterator.hpp:16
void increment()
Definition: id_iterator.hpp:30
const std::string id2
Definition: file_ostream_variant_run.cpp:25