From: dahyeong.kim Date: Wed, 20 Mar 2013 07:35:07 +0000 (+0900) Subject: When the collection is empty, both begin and end should be equal X-Git-Tag: accepted/tizen_2.1/20130425.034849~247^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4e67e622cd41698f604d01049d0e0e08d0cdb585;p=framework%2Fosp%2Fappfw.git When the collection is empty, both begin and end should be equal Change-Id: Ib871174294537e98d6514cde0f65e56b265d6866 Signed-off-by: dahyeong.kim --- diff --git a/inc/FBaseColIteratorT.h b/inc/FBaseColIteratorT.h index 689d60e..4fe967a 100644 --- a/inc/FBaseColIteratorT.h +++ b/inc/FBaseColIteratorT.h @@ -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; } } diff --git a/inc/FBaseColPairIteratorT.h b/inc/FBaseColPairIteratorT.h index 0e371db..dafebc8 100644 --- a/inc/FBaseColPairIteratorT.h +++ b/inc/FBaseColPairIteratorT.h @@ -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; } }