Merge "When the collection is empty, both begin and end should be equal" into tizen_2.1
authorDahyeong Kim <dahyeong.kim@tizendev.org>
Wed, 20 Mar 2013 08:53:46 +0000 (17:53 +0900)
committerGerrit Code Review <gerrit2@kim11>
Wed, 20 Mar 2013 08:53:46 +0000 (17:53 +0900)
inc/FBaseColIteratorT.h
inc/FBaseColPairIteratorT.h

index 689d60e..4fe967a 100644 (file)
@@ -65,15 +65,23 @@ public:
                , __pEnum(__pList->GetBidirectionalEnumeratorN())
                , __currentObj(null)
        {
-               if (!isPostEnd)
+               if (__pList->GetCount() != 0)
                {
-                       __pEnum->MoveNext();
-                       __currentObj = static_cast< T >(__pEnum->GetCurrent());
+                       if (!__isPostEnd)
+                       {
+                               __pEnum->MoveNext();
+                               __currentObj = static_cast< T >(__pEnum->GetCurrent());
+                       }
+                       else
+                       {
+                               __index = __pList->GetCount();
+                               __pEnum->MovePrevious();
+                       }
                }
                else
                {
-                       __index = __pList->GetCount();
-                       __pEnum->MovePrevious();
+                       // Control reaches here intentionally because begin() should be equal to end()
+                       __isPostEnd = true;
                }
        }
 
index 0e371db..dafebc8 100644 (file)
@@ -68,15 +68,23 @@ public:
                , __pEnum(__pMap->GetMapEnumeratorN())
                , __currentObj()
        {
-               if (!isPostEnd)
+               if (__pMap->GetCount() != 0)
                {
-                       __pEnum->MoveNext();
-                       __currentObj.first = static_cast< K >(__pEnum->GetKey());
-                       __currentObj.second = static_cast< V >(__pEnum->GetValue());
+                       if (!__isPostEnd)
+                       {
+                               __pEnum->MoveNext();
+                               __currentObj.first = static_cast< K >(__pEnum->GetKey());
+                               __currentObj.second = static_cast< V >(__pEnum->GetValue());
+                       }
+                       else
+                       {
+                               __index = __pMap->GetCount();
+                       }
                }
                else
                {
-                       __index = __pMap->GetCount();
+                       // Control reaches here intentionally because begin() should be equal to end()
+                       __isPostEnd = true;
                }
        }
 
@@ -96,15 +104,23 @@ public:
                , __pEnum(__pMultiMap->GetMapEnumeratorN())
                , __currentObj()
        {
-               if (!__isPostEnd)
+               if (__pMultiMap->GetCount() != 0)
                {
-                       __pEnum->MoveNext();
-                       __currentObj.first = static_cast< K >(__pEnum->GetKey());
-                       __currentObj.second = static_cast< V >(__pEnum->GetValue());
+                       if (!__isPostEnd)
+                       {
+                               __pEnum->MoveNext();
+                               __currentObj.first = static_cast< K >(__pEnum->GetKey());
+                               __currentObj.second = static_cast< V >(__pEnum->GetValue());
+                       }
+                       else
+                       {
+                               __index = __pMultiMap->GetCount();
+                       }
                }
                else
                {
-                       __index = __pMultiMap->GetCount();
+                       // Control reaches here intentionally because begin() should be equal to end()
+                       __isPostEnd = true;
                }
        }