Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:52:54

0001 #ifndef Candidate_const_iterator_h
0002 #define Candidate_const_iterator_h
0003 
0004 /* \class reco::candidate::const_iterator
0005  *
0006  * \author Luca Lista, INFN
0007  *
0008  */
0009 #include "DataFormats/Candidate/interface/CandidateFwd.h"
0010 #include "DataFormats/Candidate/interface/iterator.h"
0011 
0012 namespace reco {
0013   namespace candidate {
0014     struct const_iterator {
0015       typedef const Candidate value_type;
0016       typedef const Candidate* pointer;
0017       typedef const Candidate& reference;
0018       typedef ptrdiff_t difference_type;
0019       typedef std::vector<int>::const_iterator::iterator_category iterator_category;
0020       const_iterator() : me(nullptr), i(0) {}
0021       const_iterator(pointer ime, difference_type ii) : me(ime), i(ii) {}
0022       const_iterator(const iterator& it) : me(it.me), i(it.i) {}
0023       const_iterator& operator=(const iterator& it) {
0024         me = it.me;
0025         i = it.i;
0026         return *this;
0027       }
0028       const_iterator& operator++() {
0029         ++i;
0030         return *this;
0031       }
0032       const_iterator operator++(int) {
0033         const_iterator ci = *this;
0034         ++i;
0035         return ci;
0036       }
0037       const_iterator& operator--() {
0038         --i;
0039         return *this;
0040       }
0041       const_iterator operator--(int) {
0042         const_iterator ci = *this;
0043         --i;
0044         return ci;
0045       }
0046       difference_type operator-(const const_iterator& o) const { return i - o.i; }
0047       const_iterator operator+(difference_type n) const {
0048         const_iterator ci = *this;
0049         ci.i += n;
0050         return ci;
0051       }
0052       const_iterator operator-(difference_type n) const {
0053         const_iterator ci = *this;
0054         ci.i -= n;
0055         return ci;
0056       }
0057       bool operator<(const const_iterator& o) { return i < o.i; }
0058       bool operator==(const const_iterator& ci) const { return i == ci.i; }
0059       bool operator!=(const const_iterator& ci) const { return i != ci.i; }
0060       inline reference operator*() const;
0061       pointer operator->() const { return &(operator*()); }
0062       const_iterator& operator+=(difference_type d) {
0063         i += d;
0064         return *this;
0065       }
0066       const_iterator& operator-=(difference_type d) {
0067         i -= d;
0068         return *this;
0069       }
0070 
0071     private:
0072       pointer me;
0073       difference_type i;
0074     };
0075 
0076   }  // namespace candidate
0077 }  // namespace reco
0078 
0079 #endif