When the collection is empty, both begin and end should be equal
authordahyeong.kim <dahyeong.kim@samsung.com>
Wed, 20 Mar 2013 07:35:07 +0000 (16:35 +0900)
committerdahyeong.kim <dahyeong.kim@samsung.com>
Wed, 20 Mar 2013 07:35:07 +0000 (16:35 +0900)
Change-Id: Ib871174294537e98d6514cde0f65e56b265d6866
Signed-off-by: dahyeong.kim <dahyeong.kim@samsung.com>
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;
                }
        }