00001
00002
00003 #ifndef _KEY_ITERATOR_H
00004 #define _KEY_ITERATOR_H
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080 #include "../macros.h"
00081 #include "../String.h"
00082
00083 #include "BaseIter.h"
00084 #include "TypedBaseMap.h"
00085 #include "TypedBaseRefMap.h"
00086
00087 #include "ghost_enum.h"
00088
00089 template <class S, class T> class KeyIterator {
00090 private:
00091 BaseIter _iter;
00092
00093 public:
00094 INLINE T ¤t_data();
00095
00096
00097
00098 INLINE const S ¤t_key() const;
00099 INLINE S ¤t_key();
00100
00101
00102
00103 INLINE void reset();
00104
00105 INLINE void set_to_last();
00106
00107
00108
00109 INLINE void next(iter_option option = STOP_ON_GHOSTS);
00110
00111
00112 INLINE void operator++ ();
00113
00114
00115
00116 INLINE void prev(iter_option option = STOP_ON_GHOSTS);
00117
00118
00119 INLINE void operator-- ();
00120
00121
00122
00123 INLINE Boolean end();
00124
00125
00126 INLINE Boolean valid();
00127
00128
00129 INLINE Boolean current_valid() const;
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147 INLINE Boolean current_invalid() const;
00148
00149
00150 INLINE KeyIterator(const KeyIterator<S, T> &other);
00151
00152
00153
00154
00155 INLINE KeyIterator<S, T> & operator = (const KeyIterator<S, T> &other);
00156
00157
00158
00159
00160
00161
00162 INLINE KeyIterator(const TypedBaseMap<S, T> &map,
00163 iter_option option = STOP_ON_GHOSTS);
00164
00165
00166
00167
00168
00169 INLINE KeyIterator<S, T> & operator = (const TypedBaseMap<S, T> &map);
00170
00171 INLINE KeyIterator(const TypedBaseRefMap<S, T> &map,
00172 iter_option option = STOP_ON_GHOSTS);
00173
00174
00175
00176
00177
00178 INLINE KeyIterator<S, T> & operator = (const TypedBaseRefMap<S, T> &map);
00179
00180 INLINE ~KeyIterator();
00181 };
00182
00183
00184
00185 template <class S, class T>
00186 INLINE T &
00187 KeyIterator<S, T>::current_data()
00188 {
00189 return (T &) _iter.current();
00190 }
00191
00192 template <class S, class T>
00193 INLINE const S &
00194 KeyIterator<S, T>::current_key() const
00195 {
00196 const S &key = *((S *) _iter.current_key());
00197
00198 return key;
00199 }
00200
00201 template <class S, class T>
00202 INLINE S &
00203 KeyIterator<S, T>::current_key()
00204 {
00205 S &key = *((S *) _iter.current_key());
00206
00207 return key;
00208 }
00209
00210 template <class S, class T>
00211 INLINE void
00212 KeyIterator<S, T>::reset()
00213 {
00214 _iter.reset();
00215 }
00216
00217 template <class S, class T>
00218 INLINE void
00219 KeyIterator<S, T>::set_to_last()
00220 {
00221 _iter.set_to_last();
00222 }
00223
00224 template <class S, class T>
00225 INLINE void
00226 KeyIterator<S, T>::next(iter_option option GIV(STOP_ON_GHOSTS))
00227 {
00228 _iter.next(option);
00229 }
00230
00231 template <class S, class T>
00232 INLINE void
00233 KeyIterator<S, T>::operator++ ()
00234 {
00235 _iter.next(_iter.skip_ghosts() ? SKIP_GHOSTS : STOP_ON_GHOSTS);
00236 }
00237
00238 template <class S, class T>
00239 INLINE void
00240 KeyIterator<S, T>::prev(iter_option option GIV(STOP_ON_GHOSTS))
00241 {
00242 _iter.prev(option);
00243 }
00244
00245 template <class S, class T>
00246 INLINE void
00247 KeyIterator<S, T>::operator-- ()
00248 {
00249 _iter.prev(_iter.skip_ghosts() ? SKIP_GHOSTS : STOP_ON_GHOSTS);
00250 }
00251
00252 template <class S, class T>
00253 INLINE Boolean
00254 KeyIterator<S, T>::end()
00255 {
00256 return _iter.end();
00257 }
00258
00259 template <class S, class T>
00260 INLINE Boolean
00261 KeyIterator<S, T>::valid()
00262 {
00263 return _iter.valid();
00264 }
00265
00266 template <class S, class T>
00267 INLINE Boolean
00268 KeyIterator<S, T>::current_valid() const
00269 {
00270 return _iter.current_valid();
00271 }
00272
00273 template <class S, class T>
00274 INLINE Boolean
00275 KeyIterator<S, T>::current_invalid() const
00276 {
00277 return _iter.current_invalid();
00278 }
00279
00280 template <class S, class T>
00281 INLINE
00282 KeyIterator<S, T>::KeyIterator(const KeyIterator<S, T> &other)
00283 : _iter(other._iter)
00284 {
00285
00286 }
00287
00288 template <class S, class T>
00289 INLINE KeyIterator<S, T> &
00290 KeyIterator<S,T>::operator = (const KeyIterator<S, T> &other)
00291 {
00292 _iter = other._iter;
00293 return *this;
00294 }
00295
00296 template <class S, class T>
00297 INLINE
00298 KeyIterator<S, T>::KeyIterator(const TypedBaseMap<S, T> &map,
00299 iter_option option GIV(STOP_ON_GHOSTS))
00300 : _iter(map._base_data_list(), option)
00301 {
00302
00303 }
00304
00305 template <class S, class T>
00306 INLINE KeyIterator<S, T> &
00307 KeyIterator<S, T>::operator = (const TypedBaseMap<S, T> &map)
00308 {
00309 _iter = map._base_data_list();
00310 return *this;
00311 }
00312
00313 template <class S, class T>
00314 INLINE
00315 KeyIterator<S, T>::KeyIterator(const TypedBaseRefMap<S, T> &map,
00316 iter_option option GIV(STOP_ON_GHOSTS))
00317 : _iter(map._base_data_list(), option)
00318 {
00319
00320 }
00321
00322 template <class S, class T>
00323 INLINE KeyIterator<S, T> &
00324 KeyIterator<S, T>::operator = (const TypedBaseRefMap<S, T> &map)
00325 {
00326 _iter = map._base_data_list();
00327 return *this;
00328 }
00329
00330 template <class S, class T>
00331 INLINE
00332 KeyIterator<S, T>::~KeyIterator()
00333 {
00334
00335 }
00336
00337 #endif