本文整理汇总了C++中DynArray::Clear方法的典型用法代码示例。如果您正苦于以下问题:C++ DynArray::Clear方法的具体用法?C++ DynArray::Clear怎么用?C++ DynArray::Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DynArray
的用法示例。
在下文中一共展示了DynArray::Clear方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void SimpleSortedSetData< KeyT, CompareKeyT, AllocatorT >::GetItems( DynArray< DataPtr >& items ) const
{
items.Clear();
items.Reserve( m_Data->GetSize() );
DataType::ConstIterator itr = m_Data->Begin();
DataType::ConstIterator end = m_Data->End();
for ( ; itr != end; ++itr )
{
HELIUM_VERIFY( items.New( Data::Bind( const_cast< KeyT& >( *itr ), m_Instance, m_Field ) ) );
}
}
示例2: main
int main()
{
DynArray <char> a;
DynArray <char> b;
char c = 'c';
char d = 'd';
char e = 'e';
char f = 'f';
char g = 'g';
a.Push_Back(c);
a.Push_Back(d);
b.Push_Back(e);
b.Push_Back(f);
char result = a.At(0,result);
//a = c,d
//b = e,f
printf("At 0: %c\n", result);
printf("A at 0,1: %c,%c\nB at 0,1: %c,%c\n", a[0], a[1], b[0], b[1]);
a.Clear();
printf("A clear... Size: %i\n", a.Size());
a.Push_Back(c);
a.Push_Back(d);
a += b;
printf("A after += : %c,%c,%c,%c\n", a[0], a[1], a[2], a[3]);
printf("A[0] = %c, A[3] = %c\n", a[0], a[3]);
printf("A.GetData = %p\n", a.GetData());
printf("Capacity: %i, size = %i\n", a.Capacity(), a.Size());
printf("Empty: ");
if (a.Empty())
{
printf("yes\n");
}
else
{
printf("no\n");
}
a.Flip();
printf("A fliped: %c,%c,%c,%c\n", a[0], a[1], a[2], a[3]);
a.Push_Back(c);
a.Push_Back(d);
a.Push_Back(e);
a.Push_Back(f);
a.Insert(2, g);
printf("A inserted g in 2: %c,%c,%c,%c,%c,%c,%c,%c,%c\n", a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8]);
a.Erase(1);
printf("A: %s\n", a.GetData());
DynArray <int> test;
int swaps = 0;
int z;
time_t t;
test.Push_Back(5);
test.Push_Back(8);
test.Push_Back(3);
test.Push_Back(1);
test.Push_Back(4);
test.Push_Back(2);
printf("Int Array : %i,%i,%i,%i,%i,%i\n", test[0], test[1], test[2], test[3], test[4], test[5]);
swaps = test.BubbleSort();
printf("Int Array : %i,%i,%i,%i,%i,%i\nSwaps: %i\n", test[0], test[1], test[2], test[3], test[4], test[5], swaps);
DynArray <int> test2;
time(&t);
srand(t);
for (int i = 0; i <= 1000; i++)
{
z = rand();
test2.Push_Back(z);
}
system("pause");
return 0;
}
示例3: GetPropertyTagNames
/// Get the list of property tag names.
///
/// Property tag names are formatted as follows:
/// - Top-level properties will contain just a name string (i.e. "m_width").
/// - Properties of structures are identified with the structure name followed by a dot, then followed by the member
/// name (i.e. "m_parameters.type").
/// - Array elements are identified with the array name followed by the element index in brackets (i.e.
/// "m_children[3]").
/// - Arrays can be nested within structs, and structs can be nested within other structs as well as arrays. When
/// this occurs, a dot is used to separate the nested elements (i.e. "m_children[3].parameters.type", where
/// "m_children" is an array of structs, "parameters" is a struct member within the array element, and "type" is
/// a member of the "parameters" struct).
///
/// Note that this is only supported for loading serializers (where GetMode() returns MODE_LOAD) that support tag
/// resolution (where CanResolveTags() returns true). This can also be fairly slow, so it should not be used in
/// production runtime code.
///
/// @param[out] rTagNames List of property tag names. The existing contents of this array will be erased.
void Serializer::GetPropertyTagNames( DynArray< String >& rTagNames ) const
{
HELIUM_TRACE( TRACE_WARNING, TXT( "Serializer::GetPropertyTagNames(): Called on an unsupported serializer.\n" ) );
rTagNames.Clear();
}
示例4: SynchronizeShaderParameters
/// Synchronize the shader parameter list with those provided by the selected shader variant.
///
/// @see SynchronizeFloatVectorParameters(), SynchronizeTextureParameters()
void Material::SynchronizeShaderParameters()
{
Shader* pShader = m_spShader;
if( !pShader )
{
m_float1Parameters.Clear();
m_float2Parameters.Clear();
m_float3Parameters.Clear();
m_float4Parameters.Clear();
m_textureParameters.Clear();
}
// Synchronize floating-point constant parameters.
Name parameterConstantBufferName = GetParameterConstantBufferName();
size_t existingFloat1Count = m_float1Parameters.GetSize();
size_t existingFloat2Count = m_float2Parameters.GetSize();
size_t existingFloat3Count = m_float3Parameters.GetSize();
size_t existingFloat4Count = m_float4Parameters.GetSize();
DynArray< Float1Parameter > newFloat1Parameters;
DynArray< Float2Parameter > newFloat2Parameters;
DynArray< Float3Parameter > newFloat3Parameters;
DynArray< Float4Parameter > newFloat4Parameters;
for( size_t shaderTypeIndex = 0; shaderTypeIndex < HELIUM_ARRAY_COUNT( m_shaderVariants ); ++shaderTypeIndex )
{
ShaderVariant* pShaderVariant = m_shaderVariants[ shaderTypeIndex ];
if( !pShaderVariant )
{
continue;
}
const ShaderConstantBufferInfoSet* pBufferSet = pShaderVariant->GetConstantBufferInfoSet( 0 );
if( !pBufferSet )
{
continue;
}
bool bCheckDuplicates =
( !newFloat1Parameters.IsEmpty() || !newFloat2Parameters.IsEmpty() || !newFloat3Parameters.IsEmpty() ||
!newFloat4Parameters.IsEmpty() );
const DynArray< ShaderConstantBufferInfo >& rBuffers = pBufferSet->buffers;
size_t bufferCount = rBuffers.GetSize();
for( size_t bufferIndex = 0; bufferIndex < bufferCount; ++bufferIndex )
{
const ShaderConstantBufferInfo& rBufferInfo = rBuffers[ bufferIndex ];
if( rBufferInfo.name != parameterConstantBufferName )
{
continue;
}
const DynArray< ShaderConstantInfo >& rConstants = rBufferInfo.constants;
size_t constantCount = rConstants.GetSize();
for( size_t constantIndex = 0; constantIndex < constantCount; ++constantIndex )
{
const ShaderConstantInfo& rConstantInfo = rConstants[ constantIndex ];
// Constants must be between 1 and 4 floating-point values.
uint16_t constantSize = rConstantInfo.usedSize;
if( constantSize < sizeof( float32_t ) || constantSize > sizeof( float32_t ) * 4 )
{
continue;
}
Name constantName = rConstantInfo.name;
size_t parameterIndex;
if( bCheckDuplicates )
{
size_t parameterCount = newFloat1Parameters.GetSize();
for( parameterIndex = 0; parameterIndex < parameterCount; ++parameterIndex )
{
if( newFloat1Parameters[ parameterIndex ].name == constantName )
{
break;
}
}
if( parameterIndex < parameterCount )
{
continue;
}
parameterCount = newFloat2Parameters.GetSize();
for( parameterIndex = 0; parameterIndex < parameterCount; ++parameterIndex )
{
if( newFloat2Parameters[ parameterIndex ].name == constantName )
{
break;
}
}
if( parameterIndex < parameterCount )
{
continue;
}
//.........这里部分代码省略.........