CMS 3D CMS Logo

MapIterator.h

Go to the documentation of this file.
00001 #ifndef CLASSLIB_MAP_ITERATOR_H
00002 # define CLASSLIB_MAP_ITERATOR_H
00003 
00004 //<<<<<< INCLUDES                                                       >>>>>>
00005 
00006 # include "classlib/sysapi/system.h"
00007 # include <iterator>
00008 
00009 namespace lat {
00010 //<<<<<< PUBLIC DEFINES                                                 >>>>>>
00011 //<<<<<< PUBLIC CONSTANTS                                               >>>>>>
00012 //<<<<<< PUBLIC TYPES                                                   >>>>>>
00013 //<<<<<< PUBLIC VARIABLES                                               >>>>>>
00014 //<<<<<< PUBLIC FUNCTIONS                                               >>>>>>
00015 //<<<<<< CLASS DECLARATIONS                                             >>>>>>
00016 
00019 template <class M> class MapValueIterator
00020 {
00021 public:
00022     // typedef typename iterator::iterator_category     iterator_category;
00023     // typedef typename iterator::difference_type       difference_type;
00024     typedef std::bidirectional_iterator_tag             iterator_category;
00025     typedef typename M::const_iterator                  base_iterator;
00026     typedef typename M::mapped_type                     value_type;
00027     typedef typename M::difference_type                 difference_type;
00028     typedef const value_type &                          reference;
00029     typedef const value_type *                          pointer;
00030 
00031     MapValueIterator (void);
00032     MapValueIterator (base_iterator i);
00033     // default copy constructor
00034     // default destructor
00035     // default assignment operator
00036 
00037     bool                operator== (const MapValueIterator &x) const;
00038     bool                operator!= (const MapValueIterator &x) const;
00039 
00040     reference           operator* (void) const;
00041     pointer             operator-> (void) const;
00042 
00043     MapValueIterator &  operator++ (void);
00044     MapValueIterator    operator++ (int);
00045     MapValueIterator &  operator-- (void);
00046     MapValueIterator    operator-- (int);
00047 
00048 private:
00049     base_iterator       m_iterator;
00050 };
00051 
00054 template <class M> class MapKeyIterator
00055 {
00056 public:
00057     // typedef typename iterator::iterator_category     iterator_category;
00058     // typedef typename iterator::difference_type       difference_type;
00059     typedef std::bidirectional_iterator_tag             iterator_category;
00060     typedef typename M::const_iterator                  base_iterator;
00061     typedef typename M::key_type                        value_type;
00062     typedef typename M::difference_type                 difference_type;
00063     typedef const value_type &                          reference;
00064     typedef const value_type *                          pointer;
00065 
00066     MapKeyIterator (void);
00067     MapKeyIterator (base_iterator i);
00068     // default copy constructor
00069     // default destructor
00070     // default assignment operator
00071 
00072     bool                operator== (const MapKeyIterator &x) const;
00073     bool                operator!= (const MapKeyIterator &x) const;
00074 
00075     reference           operator* (void) const;
00076     pointer             operator-> (void) const;
00077 
00078     MapKeyIterator &    operator++ (void);
00079     MapKeyIterator      operator++ (int);
00080     MapKeyIterator &    operator-- (void);
00081     MapKeyIterator      operator-- (int);
00082 
00083 private:
00084     base_iterator       m_iterator;
00085 };
00086 
00087 //<<<<<< INLINE PUBLIC FUNCTIONS                                        >>>>>>
00088 //<<<<<< INLINE MEMBER FUNCTIONS                                        >>>>>>
00089 
00090 template <class M> inline
00091 MapValueIterator<M>::MapValueIterator (void)
00092 {}
00093 
00094 template <class M> inline
00095 MapValueIterator<M>::MapValueIterator (base_iterator i)
00096     : m_iterator (i)
00097 {}
00098 
00099 template <class M> inline bool
00100 MapValueIterator<M>::operator== (const MapValueIterator &x) const
00101 { return m_iterator == x.m_iterator; }
00102 
00103 template <class M> inline bool
00104 MapValueIterator<M>::operator!= (const MapValueIterator &x) const
00105 { return m_iterator != x.m_iterator; }
00106 
00107 template <class M> inline typename MapValueIterator<M>::reference
00108 MapValueIterator<M>::operator* (void) const
00109 { return m_iterator->second; }
00110 
00111 template <class M> inline typename MapValueIterator<M>::pointer
00112 MapValueIterator<M>::operator-> (void) const
00113 { return &m_iterator->second; }
00114 
00115 template <class M> inline MapValueIterator<M> &
00116 MapValueIterator<M>::operator++ (void)
00117 { ++m_iterator; return *this; }
00118 
00119 template <class M> inline MapValueIterator<M>
00120 MapValueIterator<M>::operator++ (int)
00121 { return MapValueIterator (m_iterator++); }
00122 
00123 template <class M> inline MapValueIterator<M> &
00124 MapValueIterator<M>::operator-- (void)
00125 { --m_iterator; return *this; }
00126 
00127 template <class M> inline MapValueIterator<M>
00128 MapValueIterator<M>::operator-- (int)
00129 { return MapValueIterator (m_iterator--); }
00130 
00134 template <class M> inline
00135 MapKeyIterator<M>::MapKeyIterator (void)
00136 {}
00137 
00138 template <class M> inline
00139 MapKeyIterator<M>::MapKeyIterator (base_iterator i)
00140     : m_iterator (i)
00141 {}
00142 
00143 template <class M> inline bool
00144 MapKeyIterator<M>::operator== (const MapKeyIterator &x) const
00145 { return m_iterator == x.m_iterator; }
00146 
00147 template <class M> inline bool
00148 MapKeyIterator<M>::operator!= (const MapKeyIterator &x) const
00149 { return m_iterator != x.m_iterator; }
00150 
00151 template <class M> inline typename MapKeyIterator<M>::reference
00152 MapKeyIterator<M>::operator* (void) const
00153 { return m_iterator->first; }
00154 
00155 template <class M> inline typename MapKeyIterator<M>::pointer
00156 MapKeyIterator<M>::operator-> (void) const
00157 { return &m_iterator->first; }
00158 
00159 template <class M> inline MapKeyIterator<M> &
00160 MapKeyIterator<M>::operator++ (void)
00161 { ++m_iterator; return *this; }
00162 
00163 template <class M> inline MapKeyIterator<M>
00164 MapKeyIterator<M>::operator++ (int)
00165 { return MapKeyIterator (m_iterator++); }
00166 
00167 template <class M> inline MapKeyIterator<M> &
00168 MapKeyIterator<M>::operator-- (void)
00169 { --m_iterator; return *this; }
00170 
00171 template <class M> inline MapKeyIterator<M>
00172 MapKeyIterator<M>::operator-- (int)
00173 { return MapKeyIterator (m_iterator--); }
00174 
00175 } // namespace lat
00176 #endif // CLASSLIB_MAP_ITERATOR_H

Generated on Tue Jun 9 17:38:54 2009 for CMSSW by  doxygen 1.5.4