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);
228 template <AkUInt32 uCount>
233 if (in_CurrentArraySize < uCount)
234 return uCount - in_CurrentArraySize;
237 return in_CurrentArraySize + (in_CurrentArraySize >> 1);
246 if ( in_CurrentArraySize == 0 )
249 return in_CurrentArraySize + ( in_CurrentArraySize >> 1 );
254 #define AkGrowByPolicy_DEFAULT AkGrowByPolicy_Proportional
257 template <
class T,
class ARG_T,
class TAlloc = ArrayPoolDefault,
class TGrowBy = AkGrowByPolicy_DEFAULT,
class TMovePolicy = AkAssignmentMovePolicy<T> >
class AkArray :
public TAlloc
341 #endif // #ifndef SWIG
362 Iterator it =
Begin();
364 for ( Iterator itEnd =
End(); it != itEnd; ++it )
366 if ( *it == in_Item )
381 while ( uNumToSearch > 0 )
383 pPivot = pBase + ( uNumToSearch >> 1 );
384 if ( in_Item == *pPivot )
387 result.pItem = pPivot;
391 if ( in_Item > *pPivot )
403 Iterator
Erase( Iterator& in_rIter )
407 if (TMovePolicy::IsTrivial())
409 T* pItem = in_rIter.pItem;
416 if (pItem < pLastItem)
421 (
AkUInt32)(pLastItem - pItem) *
sizeof(T)
430 for (T* pItem = in_rIter.pItem; pItem < pItemLast; pItem++)
431 TMovePolicy::Move(pItem[0], pItem[1]);
443 void Erase(
unsigned int in_uIndex )
447 if (TMovePolicy::IsTrivial())
469 for (T* pItem =
m_pItems + in_uIndex; pItem < pItemLast; pItem++)
470 TMovePolicy::Move(pItem[0], pItem[1]);
488 TMovePolicy::Move( *in_rIter.pItem,
Last( ) );
505 Iterator.pItem =
m_pItems + in_uIndex;
511 return TGrowBy::GrowBy( 1 ) != 0;
536 AKASSERT(!
"AkArray calling Reserve() with AkGrowByPolicy_NoGrow is only allowed when reserved size is zero");
586 Iterator it =
FindEx( in_Item );
587 return ( it !=
End() ) ? it.pItem : 0;
596 #if defined(_MSC_VER)
597 #pragma warning( push )
598 #pragma warning( disable : 4127 )
605 #if defined(_MSC_VER)
606 #pragma warning( pop )
648 Iterator it =
FindEx( in_rItem );
662 Iterator it =
FindEx( in_rItem );
675 for ( Iterator it =
Begin(), itEnd =
End(); it != itEnd; ++it )
698 if (T* ptr =
Insert(index))
717 #if defined(_MSC_VER)
718 #pragma warning( push )
719 #pragma warning( disable : 4127 )
726 #if defined(_MSC_VER)
727 #pragma warning( pop )
733 if (TMovePolicy::IsTrivial())
758 for (T* pItem = pItemLast; pItem > (
m_pItems + in_uIndex); --pItem)
759 TMovePolicy::Move(pItem[0], pItem[-1]);
784 T * pNewItems =
NULL;
788 if (
m_pItems && TMovePolicy::IsTrivial())
790 pNewItems = (T *)TAlloc::ReAlloc(
m_pItems,
sizeof(T) * cItems,
sizeof(T) * ulNewReserve);
796 pNewItems = (T *)TAlloc::Alloc(
sizeof(T) * ulNewReserve);
803 for (
size_t i = 0; i < cItems; ++i)
807 TMovePolicy::Move(pNewItems[i],
m_pItems[i]);
825 if (in_uiSize < cItems)
827 for (
AkUInt32 i = in_uiSize; i < cItems; i++)
843 for(
size_t i = cItems; i < in_uiSize; i++)
856 TAlloc::TransferMem( (
void*&)
m_pItems, in_rSource, (
void*)in_rSource.
m_pItems );