Merge "Fix dimming issue on KeepScreenOnState function" into tizen_2.2
[platform/framework/native/appfw.git] / inc / FBaseColIteratorT.h
index 689d60e..7e38af6 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);
@@ -36,13 +35,16 @@ namespace Tizen { namespace Base { namespace Collection
 {
 /**
  * @class      IteratorT
- * @brief      This class provides an iterator that is used to convert IList to STL containers.
- *                     StlConverter provides static methods to get this iterator from IList.
+ * @brief      This class provides an iterator that is used to convert %IList to STL containers. @n
+ *                     %StlConverter provides static methods to get this iterator from %IList.
  *
  * @since      2.1
  *
- * @remarks    This class satisfies only requirements of C++ standard library InputIterator concept due to limitations of Tizen Collection.
+ * @remarks    The %IteratorT 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 %IteratorT class provides an iterator that is used to convert IList to STL containers.
+ * StlConverter provides static methods to get this iterator from IList.
  */
 
 template < typename T >
@@ -51,12 +53,12 @@ class IteratorT
 {
 public:
        /**
-        * Initializes this instance of %IteratorT class.
+        * Initializes an instance of %IteratorT class.
         *
         * @since               2.1
         *
         * @param[in]   list             A reference to the IList instance to convert
-        * @param[in]   isPostEnd        A boolean value to check the end
+        * @param[in]   isPostEnd        A boolean value to check the end of a list
         */
        explicit IteratorT(const IList& list, bool isPostEnd = false)
                : __pList(&list)
@@ -65,20 +67,28 @@ 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;
                }
        }
 
        /**
-        * This is copy constructor of %IteratorT class.
+        * This is the copy constructor of the %IteratorT class.
         *
         * @since               2.1
         *
@@ -105,7 +115,7 @@ public:
        }
 
        /**
-        * This is assignment operator of %IteratorT class.
+        * This is an assignment operator of the %IteratorT class.
         *
         * @since               2.1
         *
@@ -120,7 +130,7 @@ public:
        }
 
        /**
-        * This is the indirection operator for %IteratorT class.
+        * This is the indirection operator for the %IteratorT class.
         *
         * @since       2.1
         *
@@ -133,11 +143,11 @@ public:
        }
 
        /**
-        * This is the structure dereference operator for %IteratorT class.
+        * This is a structure dereference operator for the %IteratorT class.
         *
         * @since       2.1
         *
-        * @return              A T type pointer equivalent to the pointer address
+        * @return              A T type pointer that is equivalent to the pointer address
         */
        T* operator->(void) const
        {
@@ -145,14 +155,14 @@ public:
        }
 
        /**
-        * Moves to the next element of the collection.
+        * Moves to the next element in the collection.
         *
         * @since               2.1
         *
         * @return              A reference to the %IteratorT type instance
         * @exception   E_SUCCESS                       The method is successful.
         * @exception   E_OUT_OF_RANGE          The iterator is outside the bounds of the list.
-        * @exception   E_INVALID_OPERATION     The current state of the instance prohibits the execution of the specified operation
+        * @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.
         */
@@ -179,12 +189,11 @@ public:
         *
         * @since       2.1
         *
-        * @return              An IteratorT instance
+        * @return              An %IteratorT instance
         * @exception   E_SUCCESS                       The method is successful.
         * @exception   E_OUT_OF_RANGE          The iterator is outside the bounds of the list.
-        * @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             It takes O(n) time to get current Enumerate point to return. So use this operator as little as possible.
         * @remarks             The specific error code can be accessed using GetLastResult() method.
         */
        IteratorT< T > operator++(int)
@@ -202,7 +211,7 @@ public:
         * @return              A reference to the %IteratorT type instance
         * @exception   E_SUCCESS                       The method is successful.
         * @exception   E_OUT_OF_RANGE          The iterator is outside the bounds of the list.
-        * @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.
         */
@@ -232,12 +241,11 @@ CATCH:
         *
         * @since               2.1
         *
-        * @return              An IteratorT instance
+        * @return              An %IteratorT instance
         * @exception   E_SUCCESS                       The method is successful.
         * @exception   E_OUT_OF_RANGE          The iterator is outside the bounds of the list.
-        * @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             It takes O(n) time to get current Enumerate point to return. So use this operator as little as possible.
         * @remarks             The specific error code can be accessed using GetLastResult() method.
         */
        IteratorT< T > operator--(int)
@@ -248,7 +256,7 @@ CATCH:
        }
 
        /**
-        *      Checks the two %IteratorT instances for equality
+        *      Checks the two %IteratorT instances for equality.
         *
         *      @since          2.1
         *
@@ -287,7 +295,7 @@ CATCH:
         *
         *      @since          2.1
         *
-        *      @return         @c true if every member of the specified %IteratorT instance is not equal to the calling instance's members, @n
+        *      @return         @c true if any member of the specified %IteratorT instance is not equal to the calling instance's members, @n
         *                              else @c false
         *      @param[in]      rhs     A reference to the %IteratorT instance on the right-hand side of the operator
         */
@@ -297,11 +305,11 @@ CATCH:
        }
 
        /**
-        *      Exchanges values of the two %IteratorT instances
+        *      Swaps values of two %IteratorT instances.
         *
         *      @since          2.1
         *
-        *      @param[in]      rhs     A reference to the %IteratorT instance to swap
+        *      @param[in]      rhs     A reference to a %IteratorT instance to swap
         */
        void swap(IteratorT< T >& rhs)
        {