$search
00001 /* -*- C++ -*- 00002 * $Id: iter.hh 957 2005-03-07 16:01:20Z sjoyeux $ 00003 */ 00004 #ifndef UTILMM_UTILS_HASH_ITER_HEADER 00005 # define UTILMM_UTILS_HASH_ITER_HEADER 00006 00007 # include "utilmm/hash/bits/table_fwd.hh" 00008 00009 namespace utilmm { 00020 namespace hash_toolbox { 00021 00022 template< typename Key, typename Value, class Extract, 00023 class Hash, class Equal > 00024 class iter; 00025 00036 template< typename Key, typename Value, class Extract, 00037 class Hash, class Equal > 00038 class const_iter { 00039 public: 00044 typedef Value value_type; 00050 typedef value_type const *pointer; 00056 typedef value_type const &reference; 00062 typedef size_t size_type; 00063 00068 const_iter(); 00076 const_iter(iter<Key, Value, Extract, Hash, Equal> const &other); 00077 00085 bool operator==(const_iter const &other) const; 00093 bool operator!=(const_iter const &other) const; 00094 00104 const_iter &operator+=(size_type delta); 00114 const_iter operator+ (size_type delta) const; 00115 00122 const_iter &operator++(); 00129 const_iter operator++(int); 00130 00138 pointer operator->() const; 00143 reference operator* () const; 00144 00145 private: 00146 typedef table<Key, Value, Extract, Hash, Equal> container_type; 00147 typedef typename container_type::node_type node_type; 00148 00149 container_type const *owner; 00150 node_type const *current; 00151 00152 const_iter(node_type const *, container_type const *); 00153 00154 template<typename K, typename V, class Ex, class H, class Eq> 00155 friend class table; 00156 }; // class utilmm::hash_toolbox::const_iter<> 00157 00158 template<typename K, typename V, class Ex, class H, class Eq> 00159 const_iter<K, V, Ex, H, Eq> operator+ 00160 (typename const_iter<K, V, Ex, H, Eq>::size_type d, 00161 const_iter<K, V, Ex, H, Eq> const &i) { 00162 return i+d; 00163 } 00164 00173 template< typename Key, typename Value, class Extract, 00174 class Hash, class Equal > 00175 class iter { 00176 public: 00181 typedef Value value_type; 00187 typedef value_type *pointer; 00192 typedef value_type &reference; 00198 typedef size_t size_type; 00199 00204 iter(); 00205 00213 bool operator==(iter const &other) const; 00221 bool operator!=(iter const &other) const; 00222 00232 iter &operator+=(size_type pos); 00242 iter operator+ (size_type pos) const; 00243 00250 iter &operator++(); 00257 iter operator++(int); 00258 00266 pointer operator->() const; 00271 reference operator* () const; 00272 00273 private: 00274 typedef table<Key, Value, Extract, Hash, Equal> container_type; 00275 typedef typename container_type::node_type node_type; 00276 00277 container_type *owner; 00278 node_type *current; 00279 00280 iter(node_type *, container_type *); 00281 00282 template<typename K, typename V, class Ex, class H, class Eq> 00283 friend class const_iter; 00284 00285 template<typename K, typename V, class Ex, class H, class Eq> 00286 friend class table; 00287 }; // class utilmm::hash_toolbox::iter<> 00288 00289 template<typename K, typename V, class Ex, class H, class Eq> 00290 iter<K, V, Ex, H, Eq> operator+ 00291 (typename iter<K, V, Ex, H, Eq>::size_type d, 00292 iter<K, V, Ex, H, Eq> const &i) { 00293 return i+d; 00294 } 00295 00296 } // namespace utilmm::hash_toolbox 00297 } // namespace utilmm 00298 00299 # define IN_UTILMM_UTILS_HASH_ITER_HEADER 00300 # include "utilmm/hash/bits/iter.tcc" 00301 # undef IN_UTILMM_UTILS_HASH_ITER_HEADER 00302 #endif // UTILMM_UTILS_HASH_ITER_HEADER 00303