Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:03:48

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