00001
#if !defined(__CORELINUXASSOCIATIVEITERATOR_HPP)
00002
#define __CORELINUXASSOCIATIVEITERATOR_HPP
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
#if !defined(__COMMON_HPP)
00025
#include <Common.hpp>
00026
#endif
00027
00028
#if !defined(__ASSOCIATIVEITERATOR_HPP)
00029
#include <AssociativeIterator.hpp>
00030
#endif
00031
00032
#if !defined(__INVALIDITERATOREXCEPTION_HPP)
00033
#include <InvalidIteratorException.hpp>
00034
#endif
00035
00036
#if !defined(__ITERATORBOUNDSEXCEPTION_HPP)
00037
#include <IteratorBoundsException.hpp>
00038
#endif
00039
00040
namespace corelinux
00041 {
00042
00050
template<
class TraverseType,
class KeyType,
class ElementType >
00051 class CoreLinuxAssociativeIterator :
00052
public AssociativeIterator<KeyType,ElementType>
00053 {
00054
public:
00055
00056
00057
00058
00059
00067 CoreLinuxAssociativeIterator(
void )
00068 throw(
InvalidIteratorException)
00069 :
00070
AssociativeIterator<KeyType,ElementType>()
00071 {
00072
throw InvalidIteratorException(LOCATION);
00073 }
00074
00081 CoreLinuxAssociativeIterator( TraverseType aBegin,
00082 TraverseType aEnd )
00083 :
00084
AssociativeIterator<KeyType,ElementType>(),
00085
theBegin( aBegin ),
00086
theEnd( aEnd ),
00087
theCurrent(
theBegin )
00088 {
00089 ;
00090 }
00091
00097
CoreLinuxAssociativeIterator
00098 (
00099
const CoreLinuxAssociativeIterator &aRef
00100 )
00101 :
00102
AssociativeIterator<KeyType,ElementType>( aRef ),
00103
theBegin( aRef.theBegin ),
00104
theEnd( aRef.theEnd ),
00105
theCurrent( aRef.theBegin )
00106 {
00107 ;
00108 }
00109
00111
00112 virtual ~CoreLinuxAssociativeIterator(
void )
00113 {
00114
theBegin =
theEnd;
00115
theCurrent = theEnd;
00116 }
00117
00118
00119
00120
00121
00128
CoreLinuxAssociativeIterator &
operator=
00129 (
const CoreLinuxAssociativeIterator & aRef )
00130 {
00131
theBegin = aRef.theBegin;
00132
theEnd = aRef.theEnd;
00133
theCurrent =
theBegin;
00134
return (*this);
00135 }
00136
00144
bool operator==
00145 (
00146
const CoreLinuxAssociativeIterator & aRef
00147 )
const
00148 {
00149
return (
theBegin == aRef.theBegin &&
00150
theEnd == aRef.theEnd);
00151 }
00152
00153
00154
00155
00156
00164 virtual bool isValid(
void )
const
00165
{
00166
return !(
theCurrent ==
theEnd);
00167 }
00168
00177 virtual ElementType
getElement(
void )
00178 const throw(
IteratorBoundsException)
00179 {
00180
if( this->
isValid() ==
false )
00181 {
00182
throw IteratorBoundsException(LOCATION);
00183 }
00184
else
00185 {
00186 ;
00187 }
00188
return (*theCurrent).second;
00189 }
00190
00199 virtual KeyType
getKey(
void )
00200 const throw(
IteratorBoundsException)
00201 {
00202
if( this->
isValid() ==
false )
00203 {
00204
throw IteratorBoundsException(LOCATION);
00205 }
00206
else
00207 {
00208 ;
00209 }
00210
return (*theCurrent).first;
00211 }
00212
00213
00214
00215
00216
00218
00219 virtual void setFirst(
void )
00220 {
00221
theCurrent =
theBegin;
00222 }
00223
00230 virtual void setNext(
void )
00231 throw(
IteratorBoundsException)
00232 {
00233
if(
theCurrent !=
theEnd )
00234 {
00235 ++
theCurrent;
00236 }
00237
else
00238 {
00239
throw IteratorBoundsException(LOCATION);
00240 }
00241 }
00242
00249 virtual void setPrevious(
void )
00250 throw(
IteratorBoundsException)
00251 {
00252
if(
theCurrent !=
theBegin &&
00253
theBegin !=
theEnd )
00254 {
00255 --
theCurrent;
00256 }
00257
else
00258 {
00259
throw IteratorBoundsException(LOCATION);
00260 }
00261 }
00262
00264
00265 virtual void setLast(
void )
00266 throw(
IteratorBoundsException)
00267 {
00268
theCurrent =
theEnd;
00269
setPrevious();
00270 }
00271
00272
00273
00274
00275
00276
protected:
00277
00278
00279
00280
00281
00282
protected:
00283
00285
00286 TraverseType
theBegin;
00287
00289
00290 TraverseType
theEnd;
00291
00293
00294 TraverseType
theCurrent;
00295
00296 };
00297 }
00298
00299
#endif // if !defined(__CORELINUXASSOCIATIVEITERATOR_HPP)
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310