当前位置: 首页>>代码示例>>C++>>正文


C++ DynamicArray::Remove方法代码示例

本文整理汇总了C++中DynamicArray::Remove方法的典型用法代码示例。如果您正苦于以下问题:C++ DynamicArray::Remove方法的具体用法?C++ DynamicArray::Remove怎么用?C++ DynamicArray::Remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DynamicArray的用法示例。


在下文中一共展示了DynamicArray::Remove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ParseLine

/// Parse the given shader source line for toggle and select options.
///
/// @param[in] shaderPath     GameObject path of the shader resource being preprocessed (used for logging purposes
///                           only).
/// @param[in] rResourceData  Persistent shader resource data to update.
/// @param[in] pLineStart     Pointer to the first character in the line.
/// @param[in] pLineEnd       Pointer to the character just past the end of the line.
void ShaderResourceHandler::ParseLine(
                                      GameObjectPath shaderPath,
                                      Shader::PersistentResourceData& rResourceData,
                                      const char* pLineStart,
                                      const char* pLineEnd )
{
    HELIUM_UNREF( shaderPath );  // Not used if logging is disabled.

    HELIUM_ASSERT( pLineStart );
    HELIUM_ASSERT( pLineEnd >= pLineStart );

    const char linePrefix[] = "//!";
    const char toggleUserCommand[] = "@toggle";
    const char selectUserCommand[] = "@select";
    const char toggleSystemCommand[] = "@systoggle";
    const char selectSystemCommand[] = "@sysselect";

    size_t characterCount = static_cast< size_t >( pLineEnd - pLineStart );

    // Only process lines that start with the special comment prefix.
    if( characterCount < HELIUM_ARRAY_COUNT( linePrefix ) - 1 ||
        CompareString( pLineStart, linePrefix, HELIUM_ARRAY_COUNT( linePrefix ) - 1 ) != 0 )
    {
        return;
    }

    pLineStart += HELIUM_ARRAY_COUNT( linePrefix ) - 1;
    characterCount -= HELIUM_ARRAY_COUNT( linePrefix ) - 1;

    // Split the line based on groups of whitespaces.
    CharString line( pLineStart, characterCount );

    DynamicArray< CharString > splitLine;
    line.Split( splitLine, " \t\v\f", Invalid< size_t >(), true );

    // Ignore the first split if it's empty (will occur if the command is preceded by whitespaces).
    size_t splitCount = splitLine.GetSize();
    if( splitCount > 0 && splitLine[ 0 ].IsEmpty() )
    {
        splitLine.Remove( 0 );
        --splitCount;
    }

    // We need at least 2 splits (command and at least one command parameter).
    if( splitCount < 2 )
    {
        return;
    }

    // Process the command.
    DynamicArray< CharString > splitCommand;
    splitLine[ 0 ].Split( splitCommand, '_' );
    size_t commandSplitCount = splitCommand.GetSize();
    if( commandSplitCount < 1 || commandSplitCount > 2 )
    {
        // Invalid command format.
        return;
    }

    const CharString& rCommand = splitCommand[ 0 ];

    bool bToggleUserCommand = ( rCommand == toggleUserCommand );
    bool bSelectUserCommand = ( !bToggleUserCommand && rCommand == selectUserCommand );
    bool bToggleSystemCommand = ( !( bToggleUserCommand | bSelectUserCommand ) && rCommand == toggleSystemCommand );
    bool bSelectSystemCommand =
        ( !( bToggleUserCommand | bSelectUserCommand | bToggleSystemCommand ) && rCommand == selectSystemCommand );
    if( !( bToggleUserCommand | bSelectUserCommand | bToggleSystemCommand | bSelectSystemCommand ) )
    {
        return;
    }

    /// Make sure the option name (first parameter after the command name) is valid.
    String convertedString;
    HELIUM_VERIFY( ( StringConverter< char, tchar_t >::Convert( convertedString, splitLine[ 1 ] ) ) );
    Name optionName( convertedString );
    if( optionName.IsEmpty() )
    {
        HELIUM_TRACE(
            TraceLevels::Error,
            TXT( "ShaderResourceHandler: Skipping empty option in shader resource \"%s\".\n" ),
            *shaderPath.ToString() );

        return;
    }

    // Make sure an existing toggle or selection option exists with the parsed option name.
    Shader::Options& rSystemOptions = rResourceData.GetSystemOptions();
    Shader::Options& rUserOptions = rResourceData.GetUserOptions();

    DynamicArray< Shader::Toggle >& rSystemToggles = rSystemOptions.GetToggles();
    DynamicArray< Shader::Select >& rSystemSelects = rSystemOptions.GetSelects();

    DynamicArray< Shader::Toggle >& rUserToggles = rUserOptions.GetToggles();
//.........这里部分代码省略.........
开发者ID:foolhuang,项目名称:Helium,代码行数:101,代码来源:ShaderResourceHandler.cpp

示例2: main

int main(int argc, char **argv)
{
	DynamicArray<int> a;

	std::cout << "Dynamic arrays" << std::endl;
	a.Print();

	a.Insert(4);
	a.Print();

	a.Insert(3);
	a.Print();

	a.Insert(2);
	a.Print();

	a.Insert(1);
	a.Print();

	a.Insert(0);
	a.Print();

	cout << "3rd element = " << a[2] << endl;

	a[2] = 10;
	a.Print();

	a.Remove(1);
	a.Print();

	a.Remove(2);
	a.Print();

	a.Remove(1);
	a.Print();

	a.Remove(0);
	a.Print();

	a.Remove(0);
	a.Print();

	// Double


	DynamicArray<double> b;

	std::cout << "Dynamic arrays (with double)" << std::endl;
	b.Print();

	b.Insert(4.44);
	b.Print();

	b.Insert(3.33);
	b.Print();

	b.Insert(2.22);
	b.Print();

	b.Insert(1.11);
	b.Print();

	b.Insert(0.00);
	b.Print();

	cout << "3rd element = " << b[2] << endl;

	b[2] = 10.10;
	b.Print();

	b.Remove(1);
	b.Print();

	b.Remove(2);
	b.Print();

	b.Remove(1);
	b.Print();

	b.Remove(0);
	b.Print();

	b.Remove(0);
	b.Print();
}
开发者ID:Sabreil,项目名称:School,代码行数:85,代码来源:main.cpp


注:本文中的DynamicArray::Remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。