Merge "[2.2] Add Unshareable marker in String" into tizen_2.2
[platform/framework/native/appfw.git] / inc / FBaseColPairIteratorT.h
index 0e371db..3d71646 100644 (file)
@@ -1,5 +1,4 @@
 //
-// Open Service Platform
 // Copyright (c) 2013 Samsung Electronics Co., Ltd.
 //
 // Licensed under the Apache License, Version 2.0 (the License);
@@ -38,13 +37,16 @@ namespace Tizen { namespace Base { namespace Collection
 {
 /**
  * @class      PairIteratorT
- * @brief      This class provides an iterator that is used to convert IMap or IMultiMap to STL containers.
- *                     StlConverter provides static methods to get this iterator from IMap or IMultiMap.
+ * @brief      This class provides an iterator that is used to convert %IMap or %IMultiMap to STL containers. @n
+ *                     %StlConverter provides static methods to get this iterator from %IMap or %IMultiMap.
  *
  * @since      2.1
  *
- * @remarks    This class satisfies only requirements of C++ standard library InputIterator concept due to limitations of Tizen Collection.
+ * @remarks    The %PairIteratorT class satisfies only requirements of C++ standard library InputIterator concept due to limitations of %Tizen Collection.
  *                     So, this class can be used with C++ standard library algorithms which requires only InputIterator concept for their arguments.
+ *
+ * The %PairIteratorT class provides an iterator that is used to convert IMap or IMultiMap to STL containers.
+ * StlConverter provides static methods to get this iterator from IMap or IMultiMap.
  */
 
 template < typename K, typename V >
@@ -68,15 +70,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,26 +106,34 @@ 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;
                }
        }
 
        /**
-        * This is copy constructor of %PairIteratorT class.
+        * This is the copy constructor of the %PairIteratorT class.
         *
         * @since               2.1
         *
         * @param[in]   rhs                                     A reference to the %PairIteratorT instance
         * @exception   E_SUCCESS                       The method is successful.
-        * @exception   E_INVALID_ARG           Both @c __pMap and @c __pMultiMap are null.
+        * @exception   E_INVALID_ARG           Both @c __pMap and @c __pMultiMap are @c null.
         * @exception   E_INVALID_OPERATION     The current state of the instance prohibits the execution of the specified operation, or
         *                                                                      the collection is modified after the enumerator is created.
         * @remarks             The specific error code can be accessed using GetLastResult() method.
@@ -148,15 +166,15 @@ public:
        }
 
        /**
-        * This is assignment operator of %PairIteratorT class.
+        * This is assignment operator of the %PairIteratorT class.
         *
         * @since               2.1
         *
         * @return              A reference to the %PairIteratorT instance
         * @param[in]   rhs                                     A reference to the %PairIteratorT instance on the right-hand side of the operator
         * @exception   E_SUCCESS                       The method is successful.
-        * @exception   E_INVALID_ARG           Both @c __pMap and @c __pMultiMap are null.
-        * @exception   E_INVALID_OPERATION     The current state of the instance prohibits the execution of the specified operation or
+        * @exception   E_INVALID_ARG           Both @c __pMap and @c __pMultiMap are @c null.
+        * @exception   E_INVALID_OPERATION     The current state of the instance prohibits the execution of the specified operation, or
         *                                                                      the collection is modified after the enumerator is created.
         * @remarks             The specific error code can be accessed using GetLastResult() method.
         */
@@ -168,7 +186,7 @@ public:
        }
 
        /**
-        * This is the indirection operator for %PairIteratorT class.
+        * This is the indirection operator for the %PairIteratorT class.
         *
         * @since               2.1
         *
@@ -181,7 +199,7 @@ public:
        }
 
        /**
-        * This is the const version structure dereference operator for %PairIteratorT class.
+        * This is the const version structure dereference operator for the %PairIteratorT class.
         *
         * @since               2.1
         *
@@ -200,7 +218,7 @@ public:
         * @return              A reference to the %PairIteratorT instance
         * @exception   E_SUCCESS                       The method is successful.
         * @exception   E_OUT_OF_RANGE          The enumerator has passed the end of the collection.
-        * @exception   E_INVALID_OPERATION     The current state of the instance prohibits the execution of the specified operation or
+        * @exception   E_INVALID_OPERATION     The current state of the instance prohibits the execution of the specified operation, or
         *                                                                      the collection is modified after the enumerator is created.
         * @remarks             The specific error code can be accessed using GetLastResult() method.
         */
@@ -228,7 +246,7 @@ CATCH:
         * @return              A %PairIteratorT instance
         * @exception   E_SUCCESS                       The method is successful.
         * @exception   E_OUT_OF_RANGE          The enumerator has passed the end of the collection.
-        * @exception   E_INVALID_OPERATION     The current state of the instance prohibits the execution of the specified operation or
+        * @exception   E_INVALID_OPERATION     The current state of the instance prohibits the execution of the specified operation, or
         *                                                                      the collection is modified after the enumerator is created.
         * @remarks             The specific error code can be accessed using GetLastResult() method.
         */
@@ -240,7 +258,7 @@ CATCH:
        }
 
        /**
-        *      Checks the two %PairIteratorT instances for equality
+        *      Checks the two %PairIteratorT instances for equality.
         *
         *      @since          2.1
         *
@@ -284,7 +302,7 @@ CATCH:
         *
         *      @since          2.1
         *
-        *      @return         @c true if every member of the specified %PairIteratorT instance is not equal to the calling instance's members, @n
+        *      @return         @c true if any member of the specified %PairIteratorT instance is not equal to the calling instance's members, @n
         *                              else @c false
         *      @param[in]      rhs     A reference to the %PairIteratorT instance on the right-hand side of the operator
         */
@@ -294,7 +312,7 @@ CATCH:
        }
 
        /**
-        *      Exchanges values of the two %PairIteratorT instances
+        *      Swaps values of the two %PairIteratorT instances.
         *
         *      @since          2.1
         *