本文整理汇总了C++中DynArray::Reserve方法的典型用法代码示例。如果您正苦于以下问题:C++ DynArray::Reserve方法的具体用法?C++ DynArray::Reserve怎么用?C++ DynArray::Reserve使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DynArray
的用法示例。
在下文中一共展示了DynArray::Reserve方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void SimpleSortedSetData< KeyT, CompareKeyT, AllocatorT >::Serialize( ArchiveT& archive )
{
DynArray< ObjectPtr > components;
components.Reserve( m_Data->GetSize() );
{
DataType::ConstIterator itr = m_Data->Begin();
DataType::ConstIterator end = m_Data->End();
for ( ; itr != end; ++itr )
{
ObjectPtr dataElem = Registry::GetInstance()->CreateInstance( Reflect::GetDataClass< KeyT >() );
// downcast to data type
Data* dataSer = AssertCast< Data >( dataElem );
// connect to our map data memory address
dataSer->ConnectData( const_cast< KeyT* >( &( *itr ) ) );
// serialize to the archive stream
HELIUM_VERIFY( components.New( dataSer ) );
}
}
archive.SerializeArray( components );
DynArray< ObjectPtr >::Iterator itr = components.Begin();
DynArray< ObjectPtr >::Iterator end = components.End();
for ( ; itr != end; ++itr )
{
Data* ser = AssertCast< Data >( *itr );
ser->Disconnect();
// might be useful to cache the data object here
}
}
示例2:
void SimpleObjectSortedMapData< KeyT, CompareKeyT, AllocatorT >::Serialize( ArchiveT& archive )
{
DynArray< ObjectPtr > components;
components.Reserve( m_Data->GetSize() * 2 );
{
DataType::ConstIterator itr = m_Data->Begin();
DataType::ConstIterator end = m_Data->End();
for ( ; itr != end; ++itr )
{
ObjectPtr elem = Registry::GetInstance()->CreateInstance( Reflect::GetDataClass< KeyT >() );
Data* ser = AssertCast< Data >( elem.Ptr() );
ser->ConnectData( const_cast< KeyT* >( &itr->First() ) );
HELIUM_VERIFY( components.New( ser ) );
HELIUM_VERIFY( components.New( itr->Second() ) );
}
}
archive.SerializeArray( components );
{
DynArray< ObjectPtr >::Iterator itr = components.Begin();
DynArray< ObjectPtr >::Iterator end = components.End();
for ( ; itr != end; ++itr )
{
Data* ser = AssertCast< Data >( *itr );
ser->Disconnect();
++itr; // Skip over the object reference.
// might be useful to cache the data object here
}
}
}