35 #define AK_DEFINE_ARRAY_POOL( _name_, _poolID_ ) \
38 static AkMemPoolId Get() \
47 template <
class U_POOL>
62 (*io_pDest) = in_pSrc;
66 template <
class U_POOL>
81 (*io_pDest) = in_pSrc;
90 template< AkUInt32 uBufferSizeBytes, AkUInt8 uAlignmentSize = AK_OS_STRUCT_ALIGN>
97 if (in_uSize <= uBufferSizeBytes)
98 return (
void *)&m_buffer;
105 if (&m_buffer != in_pAddress)
111 if (&in_srcAlloc.m_buffer == in_pSrc)
114 (*io_pDest) = m_buffer;
118 (*io_pDest) = in_pSrc;
122 AK_ALIGN(
char m_buffer[uBufferSizeBytes], uAlignmentSize);
142 in_Dest.Transfer(in_Src);
152 template <
class T,
class ARG_T,
class TAlloc = ArrayPoolDefault,
unsigned long TGrowBy = 1,
class TMovePolicy = AkAssignmentMovePolicy<T> >
class AkArray :
public TAlloc
230 #endif // #ifndef SWIG
251 Iterator it =
Begin();
253 for ( Iterator itEnd =
End(); it != itEnd; ++it )
255 if ( *it == in_Item )
266 Iterator itResult =
End();
271 while ( pTop <= pBottom )
273 T* pThis = ( pBottom - pTop ) / 2 + pTop;
274 if( in_Item < *pThis )
276 else if ( in_Item > *pThis )
280 itResult.pItem = pThis;
290 Iterator
Erase( Iterator& in_rIter )
298 for ( T * pItem = in_rIter.pItem; pItem < pItemLast; pItem++ )
299 TMovePolicy::Move( pItem[ 0 ], pItem[ 1 ] );
311 void Erase(
unsigned int in_uIndex )
319 for ( T * pItem =
m_pItems+in_uIndex; pItem < pItemLast; pItem++ )
320 TMovePolicy::Move( pItem[ 0 ], pItem[ 1 ] );
338 TMovePolicy::Move( *in_rIter.pItem,
Last( ) );
354 AKASSERT( in_ulReserve || TGrowBy );
358 m_pItems = (T *) TAlloc::Alloc(
sizeof( T ) * in_ulReserve );
403 Iterator it =
FindEx( in_Item );
404 return ( it !=
End() ) ? it.pItem : 0;
413 #if defined(_MSC_VER)
414 #pragma warning( push )
415 #pragma warning( disable : 4127 )
422 #if defined(_MSC_VER)
423 #pragma warning( pop )
465 Iterator it =
FindEx( in_rItem );
479 Iterator it =
FindEx( in_rItem );
492 for ( Iterator it =
Begin(), itEnd =
End(); it != itEnd; ++it )
513 #if defined(_MSC_VER)
514 #pragma warning( push )
515 #pragma warning( disable : 4127 )
522 #if defined(_MSC_VER)
523 #pragma warning( pop )
534 for ( T * pItem = pItemLast; pItem > (
m_pItems + in_uIndex ); --pItem )
535 TMovePolicy::Move( pItem[ 0 ], pItem[ -1 ] );
554 T * pNewItems = (T *) TAlloc::Alloc(
sizeof( T ) * ulNewReserve );
564 for (
size_t i = 0; i < cItems; ++i )
568 TMovePolicy::Move( pNewItems[ i ],
m_pItems[ i ] );
586 if (in_uiSize < cItems)
589 for(
AkUInt32 i = in_uiSize - 1 ; i < cItems; i++)
604 for(
size_t i = cItems; i < in_uiSize; i++)
617 TAlloc::TransferMem( (
void **)&
m_pItems, in_rSource, (
void*)in_rSource.
m_pItems );
AkForceInline void * Alloc(size_t in_uSize)
T * Exists(ARG_T in_Item) const
Returns a pointer to the specified item in the list if it exists, 0 if not found.
Iterator EraseSwap(Iterator &in_rIter)
AK_ALIGN(char m_buffer[uBufferSizeBytes], uAlignmentSize)
Iterator FindEx(ARG_T in_Item) const
Returns the iterator th the specified item, will be End() if the item is not found.
AKRESULT __cdecl Free(AkMemPoolId in_poolId, void *in_pMemAddress)
bool operator==(const Iterator &in_rOp) const
The operation was successful.
AKRESULT Copy(const AkArray< T, ARG_T, TAlloc, TGrowBy, TMovePolicy > &in_rSource)
static const AkUInt32 _uBufferSizeBytes
AkArrayAllocatorNoAlign< _ArrayPoolDefault > ArrayPoolDefault
AkForceInline AkUInt32 Length() const
Returns the numbers of items in the array.
AKRESULT
Standard function call result.
void Erase(unsigned int in_uIndex)
Erase the item at the specified index.
AKRESULT Remove(ARG_T in_rItem)
Removes the specified item if found in the array.
Iterator & operator--()
#define AK_DEFINE_ARRAY_POOL(_name_, _poolID_)
AkForceInline void AkMemCpy(void *pDest, const void *pSrc, AkUInt32 uSize)
Platform Independent Helper.
AkArrayAllocatorNoAlign< _ArrayPoolLEngineDefault > ArrayPoolLEngineDefault
Specific implementation of array.
AkForceInline void TransferMem(void **io_pDest, AkArrayAllocatorNoAlign< U_POOL > in_srcAlloc, void *in_pSrc)
#define AKASSERT(Condition)
AkForceInline void Free(void *in_pAddress)
T * m_pItems
pointer to the beginning of the array.
bool GrowArray(AkUInt32 in_uGrowBy=TGrowBy)
Resize the array.
AkForceInline void TransferMem(void **io_pDest, AkArrayAllocatorAlignedSimd< U_POOL > in_srcAlloc, void *in_pSrc)
T * pItem
Pointer to the item in the array.
Iterator End() const
Returns the iterator to the end of the array.
AKRESULT Reserve(AkUInt32 in_ulReserve)
Pre-Allocate a number of spaces in the array.
AKRESULT __cdecl Falign(AkMemPoolId in_poolId, void *in_pMemAddress)
AkForceInline void TransferMem(void **io_pDest, AkHybridAllocator< uBufferSizeBytes, uAlignmentSize > &in_srcAlloc, void *in_pSrc)
AkUInt32 m_uLength
number of items in the array.
AKRESULT RemoveSwap(ARG_T in_rItem)
AkUInt32 m_ulReserved
how many we can have at most (currently allocated).
AkForceInline bool IsEmpty() const
Returns true if the number items in the array is 0, false otherwise.
Iterator Begin() const
Returns the iterator to the first item of the array, will be End() if the array is empty.
void Transfer(AkArray< T, ARG_T, TAlloc, TGrowBy, TMovePolicy > &in_rSource)
void *__cdecl Malign(AkMemPoolId in_poolId, size_t in_uSize, AkUInt32 in_uAlignment)
Iterator operator+(AkUInt32 inc) const
void *__cdecl Malloc(AkMemPoolId in_poolId, size_t in_uSize)
static AkForceInline void Move(T &in_Dest, T &in_Src)
AkForceInline void * Alloc(size_t in_uSize)
T * AddLast(ARG_T in_rItem)
Add an item in the array, and fills it with the provided item.
Iterator BinarySearch(ARG_T in_Item) const
#define AkPlacementNew(_memory)
T & Last()
Returns a reference to the last item in the array.
AkMemPoolId g_LEngineDefaultPoolId
Iterator Erase(Iterator &in_rIter)
Erase the specified iterator from the array.
Iterator & operator++()
static AkForceInline void Move(T &in_Dest, T &in_Src)
AkUInt32 operator-(Iterator const &rhs) const
AkArrayAllocatorAlignedSimd< _ArrayPoolLEngineDefault > ArrayPoolLEngineDefaultAlignedSimd
bool operator !=(const Iterator &in_rOp) const
AkUInt32 Reserved() const
AkForceInline T & operator[](unsigned int uiIndex) const
Operator [], return a reference to the specified index.
AkMemPoolId g_DefaultPoolId
AkForceInline void * Alloc(size_t in_uSize)
void RemoveAll()
Removes all items in the array.
T * Insert(unsigned int in_uIndex)
AkForceInline void Free(void *in_pAddress)
bool Resize(AkUInt32 in_uiSize)
Resize the array to the specified size.
void RemoveLast()
Removes the last item from the array.
AkForceInline T * Data() const
Returns a pointer to the first item in the array.
AkForceInline void Free(void *in_pAddress)
void Term()
Term the array. Must be called before destroying the object.