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:
23  typedef Id_iterator self_type;
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_ */
Main namespace of vdj_pipe library.
Definition: sequence_file.hpp:14
Definition: id_iterator.hpp:16