CMS 3D CMS Logo

iterator.h
Go to the documentation of this file.
1 #ifndef Candidate_iterator_h
2 #define Candidate_iterator_h
3 
4 /* \class reco::candidate::iterator
5  *
6  * \author Luca Lista, INFN
7  *
8  */
10 
11 namespace reco {
12  namespace candidate {
13  struct const_iterator;
14  struct iterator {
16  typedef Candidate * pointer;
17  typedef Candidate & reference;
18  typedef ptrdiff_t difference_type;
19  typedef std::vector<int>::iterator::iterator_category iterator_category;
20  iterator() : me(nullptr), i( 0 ) { }
21  iterator(pointer ime, difference_type ii ) : me(ime), i(ii) { }
22  iterator& operator++() { ++i; return *this; }
23  iterator operator++( int ) { iterator ci = *this; ++i; return ci; }
24  iterator& operator--() { --i; return *this; }
25  iterator operator--( int ) { iterator ci = *this; --i; return ci; }
26  difference_type operator-( const iterator & o ) const { return i-o.i; }
27  iterator operator+( difference_type n ) const {
28  iterator ci = *this; ci.i+=n;
29  return ci;
30  }
31  iterator operator-( difference_type n ) const {
32  iterator ci = *this; ci.i-=n;
33  return ci;
34  }
35  bool operator<( const iterator & o ) { return i<o.i; }
36  bool operator==( const iterator& ci ) const { return i==ci.i; }
37  bool operator!=( const iterator& ci ) const { return i!=ci.i; }
38 
39  inline reference operator * () const;
40  pointer operator->() const { return & ( operator*() ); }
41  iterator & operator +=( difference_type d ) { i+=d; return *this; }
42  iterator & operator -=( difference_type d ) { i-=d; return *this; }
43  private:
44  pointer me;
45  difference_type i;
46  friend struct const_iterator;
47  };
48 
49  }
50 }
51 
52 #endif
iterator & operator+=(difference_type d)
Definition: iterator.h:41
std::vector< int >::iterator::iterator_category iterator_category
Definition: iterator.h:19
bool operator!=(const iterator &ci) const
Definition: iterator.h:37
pointer operator->() const
Definition: iterator.h:40
iterator operator-(difference_type n) const
Definition: iterator.h:31
ptrdiff_t difference_type
Definition: iterator.h:18
#define nullptr
Candidate & reference
Definition: iterator.h:17
difference_type i
Definition: iterator.h:45
iterator operator+(difference_type n) const
Definition: iterator.h:27
iterator operator++(int)
Definition: iterator.h:23
iterator operator--(int)
Definition: iterator.h:25
ii
Definition: cuy.py:590
bool operator<(const iterator &o)
Definition: iterator.h:35
iterator & operator--()
Definition: iterator.h:24
fixed size matrix
bool operator==(const iterator &ci) const
Definition: iterator.h:36
iterator & operator-=(difference_type d)
Definition: iterator.h:42
difference_type operator-(const iterator &o) const
Definition: iterator.h:26
iterator(pointer ime, difference_type ii)
Definition: iterator.h:21
iterator & operator++()
Definition: iterator.h:22
reference operator*() const
Definition: Candidate.h:277