36 template <AkMemID T_MEMID>
41 return AkAlloc(T_MEMID, in_uSize);
47 return AkRealloc(T_MEMID, in_pCurrent, in_uNewSize);
52 AkFree(T_MEMID, in_pAddress);
61 template <AkMemID T_MEMID>
76 AkFree(T_MEMID, in_pAddress);
90 template< AkUInt32 uBufferSizeBytes, AkUInt8 uAlignmentSize = 1, AkMemID T_MEMID = AkMemID_Object>
97 if (in_uSize <= uBufferSizeBytes)
98 return (
void *)&m_buffer;
99 return AkMalign(T_MEMID, in_uSize, uAlignmentSize);
104 if (in_uNewSize <= uBufferSizeBytes)
105 return (
void *)&m_buffer;
107 if (&m_buffer != in_pCurrent)
110 void* pAddress =
AkMalign(T_MEMID, in_uNewSize, uAlignmentSize);
120 if (&m_buffer != in_pAddress)
121 AkFree(T_MEMID, in_pAddress);
126 if (&in_srcAlloc.m_buffer == in_pSrc)
137 AK_ALIGN(
char m_buffer[uBufferSizeBytes], uAlignmentSize);
143 template <
class T, AkUInt32 uCount = 1, AkMemID MemID = AkMemID_Object>
171 io_Dest = std::move(io_Src);
186 io_Dest = std::move(io_Src);
201 in_Dest.Transfer(in_Src);
229 template <AkUInt32 uCount>
234 if (in_CurrentArraySize < uCount)
235 return uCount - in_CurrentArraySize;
238 return in_CurrentArraySize + (in_CurrentArraySize >> 1);
247 if ( in_CurrentArraySize == 0 )
250 return in_CurrentArraySize + ( in_CurrentArraySize >> 1 );
255 #define AkGrowByPolicy_DEFAULT AkGrowByPolicy_Proportional
258 template <
class T,
class ARG_T,
class TAlloc = ArrayPoolDefault,
class TGrowBy = AkGrowByPolicy_DEFAULT,
class TMovePolicy = AkAssignmentMovePolicy<T> >
class AkArray :
public TAlloc
342 #endif // #ifndef SWIG
363 Iterator it =
Begin();
365 for ( Iterator itEnd =
End(); it != itEnd; ++it )
367 if ( *it == in_Item )
382 while ( uNumToSearch > 0 )
384 pPivot = pBase + ( uNumToSearch >> 1 );
385 if ( in_Item == *pPivot )
388 result.pItem = pPivot;
392 if ( in_Item > *pPivot )
404 Iterator
Erase( Iterator& in_rIter )
408 if (TMovePolicy::IsTrivial())
410 T* pItem = in_rIter.pItem;
417 if (pItem < pLastItem)
422 (
AkUInt32)(pLastItem - pItem) *
sizeof(T)
431 for (T* pItem = in_rIter.pItem; pItem < pItemLast; pItem++)
432 TMovePolicy::Move(pItem[0], pItem[1]);
444 void Erase(
unsigned int in_uIndex )
448 if (TMovePolicy::IsTrivial())
470 for (T* pItem =
m_pItems + in_uIndex; pItem < pItemLast; pItem++)
471 TMovePolicy::Move(pItem[0], pItem[1]);
489 TMovePolicy::Move( *in_rIter.pItem,
Last( ) );
506 Iterator.pItem =
m_pItems + in_uIndex;
512 return TGrowBy::GrowBy( 1 ) != 0;
537 AKASSERT(!
"AkArray calling Reserve() with AkGrowByPolicy_NoGrow is only allowed when reserved size is zero");
587 Iterator it =
FindEx( in_Item );
588 return ( it !=
End() ) ? it.pItem : 0;
597 #if defined(_MSC_VER)
598 #pragma warning( push )
599 #pragma warning( disable : 4127 )
606 #if defined(_MSC_VER)
607 #pragma warning( pop )
649 Iterator it =
FindEx( in_rItem );
663 Iterator it =
FindEx( in_rItem );
676 for ( Iterator it =
Begin(), itEnd =
End(); it != itEnd; ++it )
699 if (T* ptr =
Insert(index))
718 #if defined(_MSC_VER)
719 #pragma warning( push )
720 #pragma warning( disable : 4127 )
727 #if defined(_MSC_VER)
728 #pragma warning( pop )
734 if (TMovePolicy::IsTrivial())
759 for (T* pItem = pItemLast; pItem > (
m_pItems + in_uIndex); --pItem)
760 TMovePolicy::Move(pItem[0], pItem[-1]);
785 T * pNewItems =
NULL;
789 if (
m_pItems && TMovePolicy::IsTrivial())
791 pNewItems = (T *)TAlloc::ReAlloc(
m_pItems,
sizeof(T) * cItems,
sizeof(T) * ulNewReserve);
797 pNewItems = (T *)TAlloc::Alloc(
sizeof(T) * ulNewReserve);
804 for (
size_t i = 0; i < cItems; ++i)
808 TMovePolicy::Move(pNewItems[i],
m_pItems[i]);
826 if (in_uiSize < cItems)
828 for (
AkUInt32 i = in_uiSize; i < cItems; i++)
844 for(
size_t i = cItems; i < in_uiSize; i++)
857 TAlloc::TransferMem( (
void*&)
m_pItems, in_rSource, (
void*)in_rSource.
m_pItems );