//
-// Open Service Platform
// Copyright (c) 2013 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the License);
{
/**
* @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 >
{
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)
, __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
*
}
/**
- * This is assignment operator of %IteratorT class.
+ * This is an assignment operator of the %IteratorT class.
*
* @since 2.1
*
}
/**
- * This is the indirection operator for %IteratorT class.
+ * This is the indirection operator for the %IteratorT class.
*
* @since 2.1
*
}
/**
- * 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
{
}
/**
- * 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.
*/
*
* @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)
* @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.
*/
*
* @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)
}
/**
- * Checks the two %IteratorT instances for equality
+ * Checks the two %IteratorT instances for equality.
*
* @since 2.1
*
*
* @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
*/
}
/**
- * 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)
{