36 template <AkMemID T_MEMID>
41 return AkAlloc(T_MEMID, in_uSize);
46 return AkRealloc(T_MEMID, in_pCurrent, in_uNewSize);
51 AkFree(T_MEMID, in_pAddress);
60 template <AkMemID T_MEMID>
75 AkFree(T_MEMID, in_pAddress);
89 template< AkUInt32 uBufferSizeBytes, AkUInt8 uAlignmentSize = 1, AkMemID T_MEMID = AkMemID_Object>
96 if (in_uSize <= uBufferSizeBytes)
97 return (
void *)&m_buffer;
98 return AkMalign(T_MEMID, in_uSize, uAlignmentSize);
103 if (in_uNewSize <= uBufferSizeBytes)
104 return (
void *)&m_buffer;
106 if (&m_buffer != in_pCurrent)
109 void* pAddress =
AkMalign(T_MEMID, in_uNewSize, uAlignmentSize);
119 if (&m_buffer != in_pAddress)
120 AkFree(T_MEMID, in_pAddress);
125 if (&in_srcAlloc.m_buffer == in_pSrc)
136 AK_ALIGN(
char m_buffer[uBufferSizeBytes], uAlignmentSize);
142 template <
class T, AkUInt32 uCount = 1, AkMemID MemID = AkMemID_Object>
170 io_Dest = std::move(io_Src);
185 io_Dest = std::move(io_Src);
200 in_Dest.Transfer(in_Src);
229 if ( in_CurrentArraySize == 0 )
232 return in_CurrentArraySize + ( in_CurrentArraySize >> 1 );
237 #define AkGrowByPolicy_DEFAULT AkGrowByPolicy_Proportional
240 template <
class T,
class ARG_T,
class TAlloc = ArrayPoolDefault,
class TGrowBy = AkGrowByPolicy_DEFAULT,
class TMovePolicy = AkAssignmentMovePolicy<T> >
class AkArray :
public TAlloc
324 #endif // #ifndef SWIG
345 Iterator it =
Begin();
347 for ( Iterator itEnd =
End(); it != itEnd; ++it )
349 if ( *it == in_Item )
364 while ( uNumToSearch > 0 )
366 pPivot = pBase + ( uNumToSearch >> 1 );
367 if ( in_Item == *pPivot )
370 result.pItem = pPivot;
374 if ( in_Item > *pPivot )
386 Iterator
Erase( Iterator& in_rIter )
390 if (TMovePolicy::IsTrivial())
392 T* pItem = in_rIter.pItem;
399 if (pItem < pLastItem)
404 (
AkUInt32)(pLastItem - pItem) *
sizeof(T)
413 for (T* pItem = in_rIter.pItem; pItem < pItemLast; pItem++)
414 TMovePolicy::Move(pItem[0], pItem[1]);
426 void Erase(
unsigned int in_uIndex )
430 if (TMovePolicy::IsTrivial())
452 for (T* pItem =
m_pItems + in_uIndex; pItem < pItemLast; pItem++)
453 TMovePolicy::Move(pItem[0], pItem[1]);
471 TMovePolicy::Move( *in_rIter.pItem,
Last( ) );
488 Iterator.pItem =
m_pItems + in_uIndex;
494 return TGrowBy::GrowBy( 1 ) != 0;
519 AKASSERT(!
"AkArray calling Reserve() with AkGrowByPolicy_NoGrow is only allowed when reserved size is zero");
569 Iterator it =
FindEx( in_Item );
570 return ( it !=
End() ) ? it.pItem : 0;
579 #if defined(_MSC_VER)
580 #pragma warning( push )
581 #pragma warning( disable : 4127 )
588 #if defined(_MSC_VER)
589 #pragma warning( pop )
631 Iterator it =
FindEx( in_rItem );
645 Iterator it =
FindEx( in_rItem );
658 for ( Iterator it =
Begin(), itEnd =
End(); it != itEnd; ++it )
679 #if defined(_MSC_VER)
680 #pragma warning( push )
681 #pragma warning( disable : 4127 )
688 #if defined(_MSC_VER)
689 #pragma warning( pop )
695 if (TMovePolicy::IsTrivial())
720 for (T* pItem = pItemLast; pItem > (
m_pItems + in_uIndex); --pItem)
721 TMovePolicy::Move(pItem[0], pItem[-1]);
746 T * pNewItems =
NULL;
750 if (
m_pItems && TMovePolicy::IsTrivial())
752 pNewItems = (T *)TAlloc::ReAlloc(
m_pItems,
sizeof(T) * cItems,
sizeof(T) * ulNewReserve);
758 pNewItems = (T *)TAlloc::Alloc(
sizeof(T) * ulNewReserve);
765 for (
size_t i = 0; i < cItems; ++i)
769 TMovePolicy::Move(pNewItems[i],
m_pItems[i]);
787 if (in_uiSize < cItems)
789 for (
AkUInt32 i = in_uiSize; i < cItems; i++)
805 for(
size_t i = cItems; i < in_uiSize; i++)
818 TAlloc::TransferMem( (
void*&)
m_pItems, in_rSource, (
void*)in_rSource.
m_pItems );