#define __DALI_VECTOR_H__
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// EXTERNAL INCLUDES
#include <cstddef>
#include <algorithm>
+#include <cstdint> // uint32_t
// INTERNAL INCLUDES
#include <dali/public-api/common/dali-common.h>
* beginning of the first real item so that iterating the items is quick.
* @SINCE_1_0.0
*/
-class DALI_IMPORT_API VectorBase
+class DALI_CORE_API VectorBase
{
public: // Typedefs
* @param[in] elementSize Size to erase
* @pre Last element cannot be erased as there is nothing to move.
*/
- void Erase( char* address, SizeType elementSize );
+ void Erase( uint8_t* address, SizeType elementSize );
/**
* @brief Erases a range of elements.
* @param[in] elementSize Size of one of the elements to be erased
* @return Address pointing to the next element of the last one
*/
- char* Erase( char* first, char* last, SizeType elementSize );
+ uint8_t* Erase( uint8_t* first, uint8_t* last, SizeType elementSize );
/**
* @brief Copies a number of bytes from \e source to \e destination.
* @param[in] source Pointer to the source address
* @param[in] numberOfBytes The number of bytes to be copied
*/
- void CopyMemory( char* destination, const char* source, size_t numberOfBytes );
+ void CopyMemory( uint8_t* destination, const uint8_t* source, size_t numberOfBytes );
private:
* @param[in] address Address to erase from
* @param[in] elementSize Size to erase
*/
- void Erase( char* address, SizeType elementSize )
+ void Erase( uint8_t* address, SizeType elementSize )
{
VectorBase::Erase( address, elementSize );
}
* @param[in] elementSize Size of one of the elements to be erased
* @return Address pointing to the next element of the last one
*/
- char* Erase( char* first, char* last, SizeType elementSize )
+ uint8_t* Erase( uint8_t* first, uint8_t* last, SizeType elementSize )
{
return VectorBase::Erase( first, last, elementSize );
}
* @param[in] to Address to the last element to be inserted
* @param[in] elementSize Size of one of the elements to be inserted
*/
- void Insert( char* at, char* from, char* to, SizeType elementSize )
+ void Insert( uint8_t* at, uint8_t* from, uint8_t* to, SizeType elementSize )
{
const SizeType size = to - from;
const SizeType count = Count();
if( newCount > Capacity() )
{
// Calculate the at offset as the pointer is invalid after the Reserve() call.
- std::size_t offset = at - reinterpret_cast<char*>( mData );
+ std::size_t offset = at - reinterpret_cast<uint8_t*>( mData );
// need more space
- Reserve( NextPowerOfTwo( newCount ), elementSize ); // reserve enough space to store at least the next power of two elements of the new required size.
+ Reserve( NextPowerOfTwo( static_cast<uint32_t>( newCount ) ), elementSize ); // reserve enough space to store at least the next power of two elements of the new required size.
// Set the new at pointer.
- at = reinterpret_cast<char*>( mData ) + offset;
+ at = reinterpret_cast<uint8_t*>( mData ) + offset;
}
// set new count first as otherwise the debug assert will hit us
SetCount( newCount );
// Move current items to a new position inside the vector.
CopyMemory( at + size,
at,
- ( reinterpret_cast<char*>( mData ) + count * elementSize ) - at );
+ ( reinterpret_cast<uint8_t*>( mData ) + count * elementSize ) - at );
// Copy the given items.
CopyMemory( at, from, size );
typedef const T* ConstIterator; ///< Const iterator @SINCE_1_0.0
typedef T ItemType; ///< Item type @SINCE_1_0.0
+ /**
+ * @brief Enumeration for BaseType.
+ * @SINCE_1_0.0
+ */
enum
{
- BaseType = IsTrivialType
+ BaseType = IsTrivialType ///< @SINCE_1_0.0
};
/**
}
/**
+ * Support for C++11 Range-based for loop: for( item : container ).
+ * @SINCE_1_2.60
+ * @return The start iterator
+ */
+ Iterator begin() const
+ {
+ return Begin();
+ }
+
+ /**
+ * Support for C++11 Range-based for loop: for( item : container ).
+ * @SINCE_1_2.60
+ * @return The end iterator
+ */
+ Iterator end() const
+ {
+ return End();
+ }
+
+ /**
* @brief Subscript operator.
* @SINCE_1_0.0
* @param[in] index Index of the element
{
DALI_ASSERT_VECTOR( ( at <= End() ) && ( at >= Begin() ) && "Iterator not inside vector" );
const SizeType size = sizeof( ItemType );
- char* address = const_cast<char*>( reinterpret_cast<const char*>( &element ) );
- VectorAlgorithms<BaseType>::Insert( reinterpret_cast< char* >( at ),
+ uint8_t* address = const_cast<uint8_t*>( reinterpret_cast<const uint8_t*>( &element ) );
+ VectorAlgorithms<BaseType>::Insert( reinterpret_cast< uint8_t* >( at ),
address,
address + size,
size );
return;
}
- VectorAlgorithms<BaseType>::Insert( reinterpret_cast< char* >( at ),
- reinterpret_cast< char* >( from ),
- reinterpret_cast< char* >( to ),
+ VectorAlgorithms<BaseType>::Insert( reinterpret_cast< uint8_t* >( at ),
+ reinterpret_cast< uint8_t* >( from ),
+ reinterpret_cast< uint8_t* >( to ),
sizeof( ItemType ) );
}
DALI_ASSERT_VECTOR( (iterator < End()) && (iterator >= Begin()) && "Iterator not inside vector" );
if( iterator < ( End() - 1u ) )
{
- VectorAlgorithms<BaseType>::Erase( reinterpret_cast< char* >( iterator ), sizeof( ItemType ) );
+ VectorAlgorithms<BaseType>::Erase( reinterpret_cast< uint8_t* >( iterator ), sizeof( ItemType ) );
}
else
{
}
else
{
- nextElement = reinterpret_cast<Iterator>( VectorAlgorithms<BaseType>::Erase( reinterpret_cast< char* >( first ),
- reinterpret_cast< char* >( last ),
+ nextElement = reinterpret_cast<Iterator>( VectorAlgorithms<BaseType>::Erase( reinterpret_cast< uint8_t* >( first ),
+ reinterpret_cast< uint8_t* >( last ),
sizeof( ItemType ) ) );
}