CMS 3D CMS Logo

iterator.h

Go to the documentation of this file.
00001 #ifndef Candidate_iterator_h
00002 #define Candidate_iterator_h
00003 
00004 /* \class reco::candidate::iterator
00005  *
00006  * \author Luca Lista, INFN
00007  *
00008  */
00009 #include "DataFormats/Candidate/interface/CandidateFwd.h"
00010 #include "DataFormats/Candidate/interface/iterator_imp.h"
00011 #include "DataFormats/Candidate/interface/const_iterator.h"
00012 
00013 namespace reco {
00014   namespace candidate {
00015     struct iterator {
00016       typedef Candidate value_type;
00017       typedef Candidate * pointer;
00018       typedef Candidate & reference;
00019       typedef ptrdiff_t difference_type;
00020       typedef std::vector<int>::iterator::iterator_category iterator_category;
00021       iterator() : i( 0 ) { }
00022       iterator( iterator_imp * it ) : i( it ) { }
00023       iterator( const iterator & it ) : i( it.i->clone() ) { }
00024       ~iterator() { delete i; }
00025       iterator & operator=( const iterator & it ) { i->assign( it.i ); return *this; }
00026       iterator& operator++() { i->increase(); return *this; }
00027       iterator operator++( int ) { iterator ci = *this; i->increase(); return ci; }
00028       iterator& operator--() { i->increase(); return *this; }
00029       iterator operator--( int ) { iterator ci = *this; i->decrease(); return ci; }
00030       difference_type operator-( const iterator & o ) const { return i->difference( o.i ); }
00031       iterator operator+( difference_type n ) const { 
00032         iterator_imp * ii = i->clone(); ii->increase( n );
00033         return iterator( ii ); 
00034       }
00035       iterator operator-( difference_type n ) const { 
00036         iterator_imp * ii = i->clone(); ii->decrease( n );
00037         return iterator( ii ); 
00038       }
00039       bool operator<( const iterator & o ) { return i->less_than( o.i ) ; }
00040       bool operator==( const iterator& ci ) const { return i->equal_to( ci.i ); }
00041       bool operator!=( const iterator& ci ) const { return ! i->equal_to( ci.i ); }
00042       Candidate & operator * () const { return i->deref(); }
00043       Candidate * operator->() const { return & ( operator*() ); }
00044       iterator & operator +=( difference_type d ) { i->increase( d ); return *this; }
00045       iterator & operator -=( difference_type d ) { i->decrease( d ); return *this; }
00046     private:
00047       iterator_imp * i;
00048       friend const_iterator::const_iterator( const iterator & );
00049     };
00050 
00051 
00052   }
00053 }
00054 
00055 #endif

Generated on Tue Jun 9 17:27:26 2009 for CMSSW by  doxygen 1.5.4