CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  */
12 
13 namespace reco {
14  namespace candidate {
15  struct iterator {
17  typedef Candidate * pointer;
18  typedef Candidate & reference;
19  typedef ptrdiff_t difference_type;
20  typedef std::vector<int>::iterator::iterator_category iterator_category;
21  iterator() : i( 0 ) { }
22  iterator( iterator_imp * it ) : i( it ) { }
23  iterator( const iterator & it ) : i( it.i->clone() ) { }
24  ~iterator() { delete i; }
25  iterator & operator=( const iterator & it ) { i->assign( it.i ); return *this; }
26  iterator& operator++() { i->increase(); return *this; }
27  iterator operator++( int ) { iterator ci = *this; i->increase(); return ci; }
28  iterator& operator--() { i->increase(); return *this; }
29  iterator operator--( int ) { iterator ci = *this; i->decrease(); return ci; }
30  difference_type operator-( const iterator & o ) const { return i->difference( o.i ); }
32  iterator_imp * ii = i->clone(); ii->increase( n );
33  return iterator( ii );
34  }
36  iterator_imp * ii = i->clone(); ii->decrease( n );
37  return iterator( ii );
38  }
39  bool operator<( const iterator & o ) { return i->less_than( o.i ) ; }
40  bool operator==( const iterator& ci ) const { return i->equal_to( ci.i ); }
41  bool operator!=( const iterator& ci ) const { return ! i->equal_to( ci.i ); }
42  Candidate & operator * () const { return i->deref(); }
43  Candidate * operator->() const { return & ( operator*() ); }
44  iterator & operator +=( difference_type d ) { i->increase( d ); return *this; }
45  iterator & operator -=( difference_type d ) { i->decrease( d ); return *this; }
46  private:
48  friend const_iterator::const_iterator( const iterator & );
49  };
50 
51 
52  }
53 }
54 
55 #endif
iterator & operator+=(difference_type d)
Definition: iterator.h:44
std::vector< int >::iterator::iterator_category iterator_category
Definition: iterator.h:20
Candidate * operator->() const
Definition: iterator.h:43
bool operator!=(const iterator &ci) const
Definition: iterator.h:41
iterator operator-(difference_type n) const
Definition: iterator.h:35
virtual void assign(const iterator_imp *)=0
virtual difference_type difference(const iterator_imp *) const =0
iterator_imp * i
Definition: iterator.h:47
ptrdiff_t difference_type
Definition: iterator.h:19
virtual bool less_than(const iterator_imp *) const =0
int ii
Definition: cuy.py:588
Candidate & operator*() const
Definition: iterator.h:42
iterator & operator=(const iterator &it)
Definition: iterator.h:25
Candidate & reference
Definition: iterator.h:18
virtual iterator_imp * clone() const =0
virtual Candidate & deref() const =0
virtual bool equal_to(const iterator_imp *) const =0
iterator operator+(difference_type n) const
Definition: iterator.h:31
iterator operator++(int)
Definition: iterator.h:27
iterator operator--(int)
Definition: iterator.h:29
bool operator<(const iterator &o)
Definition: iterator.h:39
iterator & operator--()
Definition: iterator.h:28
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
bool operator==(const iterator &ci) const
Definition: iterator.h:40
iterator & operator-=(difference_type d)
Definition: iterator.h:45
iterator(iterator_imp *it)
Definition: iterator.h:22
difference_type operator-(const iterator &o) const
Definition: iterator.h:30
iterator(const iterator &it)
Definition: iterator.h:23
iterator & operator++()
Definition: iterator.h:26