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


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

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


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

示例1: EnumerateChildren

void LoosePackageLoader::EnumerateChildren( DynamicArray< AssetPath > &children ) const
{
	for (DynamicArray< AssetPath >::ConstIterator iter = m_childPackagePaths.Begin(); 
		iter != m_childPackagePaths.End(); ++iter)
	{
		children.Add( *iter );
	}

	for (DynamicArray< SerializedObjectData >::ConstIterator iter = m_objects.Begin(); 
		iter != m_objects.End(); ++iter)
	{
		children.Add( iter->objectPath );
	}
}
开发者ID:James-Z,项目名称:Helium,代码行数:14,代码来源:LoosePackageLoader.cpp

示例2: packageDirectory

void Helium::LooseAssetLoader::EnumerateRootPackages( DynamicArray< AssetPath > &packagePaths )
{
	FilePath dataDirectory;
	FileLocations::GetDataDirectory( dataDirectory );

	DirectoryIterator packageDirectory( dataDirectory );
	for( ; !packageDirectory.IsDone(); packageDirectory.Next() )
	{
		if (packageDirectory.GetItem().m_Path.IsDirectory())
		{
			AssetPath path;

			//std::string filename = packageDirectory.GetItem().m_Path.Parent();
			std::vector< std::string > filename = packageDirectory.GetItem().m_Path.DirectoryAsVector();
			HELIUM_ASSERT(!filename.empty());
			std::string directory = filename.back();

			if (directory.size() <= 0)
			{
				continue;
			}
			path.Set( Name( directory.c_str() ), true, AssetPath(NULL_NAME) );

			packagePaths.Add( path );
		}

	}
}
开发者ID:justinliew,项目名称:Helium,代码行数:28,代码来源:LooseAssetLoader.cpp

示例3: GetPageControlList

//---------------------------------------------------------------------------
void TStemDialog::GetPageControlList(DynamicArray<HWND> &ChildList)
{
  HWND FirstChild=GetWindow(Handle,GW_CHILD);
  HWND Child=FirstChild;
  while (Child){
    if (GetDlgCtrlID(Child)<60000) ChildList.Add(Child);
    Child=GetWindow(Child,GW_HWNDNEXT);
    if (Child==FirstChild) break;
  }
}
开发者ID:TheRelentless,项目名称:steem-engine,代码行数:11,代码来源:stemdialogs.cpp

示例4: PrintArrayInfo

TEST(DataStructures, DynamicArray)
{
    {
        DynamicArray< int > intArray;
        intArray.Reserve( 3 );
        intArray.Add( 4 );
        //intArray.Add( 2 );
        HELIUM_VERIFY( intArray.New( 2 ) );
        intArray.Add( 8 );
        intArray.Add( 9 );
        intArray.Trim();

        PrintArrayInfo( TXT( "intArray" ), intArray );
    }

    {
        DynamicArray< NonTrivialClass > objectArray;
        objectArray.Reserve( 3 );
        objectArray.Add( NonTrivialClass( 4.3f ) );
        objectArray.Add( NonTrivialClass( 12.4f ) );
        objectArray.Add( NonTrivialClass( -3.9f ) );
        objectArray.Add( NonTrivialClass( 0.5f ) );
        objectArray.Add( NonTrivialClass( 2.9f ) );
        objectArray.Add( NonTrivialClass( -15.8f ) );
        objectArray.RemoveSwap( 1, 2 );
        objectArray.Trim();

        PrintArrayInfo( TXT( "objectArray" ), objectArray );
    }
}
开发者ID:KETMGaming,项目名称:Helium,代码行数:30,代码来源:GTest_Misc.cpp

示例5: ReadPtm

/***********************************************************

   ReadPtm

 ***********************************************************/
void ParserCamsi::ReadPtm(char *psz)
{
	DynamicArray<char *> aToken;

	char *p = strtok(psz, "()");
	if(!p)
		return;

	while(p){
		aToken.Add(p);
		p = strtok(NULL, "()");
	}
	
	
	TS_Ptm	*pstPtm;
	DBPtm		*pPtm;
	int			iPos;

	for(int i=0; i<aToken.GetNbElt(); i++){

		p = strtok(aToken[i], "|");

		if(!p || sscanf(p, "%d", &iPos) != 1)
			ThrowError("ParserCamsi::ReadPtm", "Ptm are bad formated");


		p = strtok(NULL, "|");

		if(!p)
			ThrowError("ParserCamsi::ReadPtm", "Ptm are bad formated");


		pPtm = DBFileWriter::GetPtm(p);

		if(pPtm){
			pstPtm = m_aPtm.Add();
			pstPtm->iPos = 0;
			pstPtm->pPtm = pPtm;
		}else{
			AddUnknownModRes(p);
		}

	}

}
开发者ID:chernan,项目名称:popitam,代码行数:50,代码来源:parserCamsi.cpp

示例6: GenRooms

// pasarle el mapdata.rooms
void GenRooms( RNG& rng, mapgen::RoomGenConfig cfg, DynamicArray<Room>& list_rooms)
{
	int w, h;
	w = cfg.map_width;
	h = cfg.map_height;
	Map map(w, h);
	Fill(map, Map::BLOCK_SOLID);
	int room_halfw = cfg.room_max_width / 2;
	int room_halfh = cfg.room_max_height / 2;

	for( int i = 0; i < cfg.num_rooms; i++ )
	{
		int room_x = rng.uniform( room_halfw+3, w - room_halfw-3 );
		int room_y = rng.uniform( room_halfh+3, h - room_halfh-3 );
		int room_w = rng.uniform( cfg.room_min_width, cfg.room_max_width );
		int room_h = rng.uniform( cfg.room_min_height, cfg.room_max_height );
		Room r(room_x, room_y, room_w, room_h);
		bool valid_room = true;
		if( cfg.overlap_control )
		{
			for( int j = 0; j < ((int)list_rooms.Size()); j++ )
			{
				if( r.Intersects( list_rooms[j] ) )
				{
					valid_room = false;
					i--;
					break;
				}
			}
			// set valid_room to false if overlaps with any existing room in list_rooms
		}
		if( valid_room )
		{
			printf("ROOM %d\n", i);
			r.Debug();
			list_rooms.Add(r);
		}
	}
}
开发者ID:,项目名称:,代码行数:40,代码来源:

示例7: InsertToTaskList

bool InsertToTaskList(A_TaskDefinitionPtr &rTaskInfoList, DynamicArray<TaskFunc> &rTaskFuncList, A_TaskDefinitionPtr &rTaskStack, const TaskDefinition *pTask)
{
	for (size_t i = 0; i < rTaskStack.GetSize(); ++i)
	{
		if (rTaskStack[i] == pTask)
		{
#if HELIUM_TOOLS
			HELIUM_TRACE(TraceLevels::Error, TXT( "Dependency cycle detected in task scheduler. Verify both explicit task order requirements as well as "
				"indirect order requirements by fulfilling/requiring TaskDefinitions. Dependency cycle is:\n" ));

			rTaskStack.Push(pTask);

			HELIUM_ASSERT(rTaskStack.GetSize() > 1);
			for (; i < rTaskStack.GetSize() - 1; ++i)
			{
				const TaskDefinition *pBeforeTask = rTaskStack[i];
				const TaskDefinition *pAfterTask = rTaskStack[i + 1];

				HELIUM_TRACE(TraceLevels::Error, TXT( " - %s must execute after %s\n"), pBeforeTask->m_Name, pAfterTask->m_Name);
			}
#else
			HELIUM_TRACE(TraceLevels::Error, TXT( "Dependency cycle detected in task scheduler. Verify both explicit task order requirements as well as "
				"indirect order requirements by fulfilling/requiring TaskDefinitions. Dependency cycle would be printed here if HELIUM_TOOLS=1\n" ));
#endif

			rTaskStack.Pop();

			// TODO: Spew the contracts of the tasks in the cycle
			return false;
		}
	}

	bool already_inserted = false;
	for (A_TaskDefinitionPtr::Iterator iter = rTaskInfoList.Begin();
		iter != rTaskInfoList.End(); ++iter)
	{
		if (*iter == pTask)
		{
			already_inserted = true;
			break;
		}
	}

	if (already_inserted)
	{
		return true;
	}

	rTaskStack.Push(pTask);

	for (A_TaskDefinitionPtr::Iterator prior_task_iter = pTask->m_RequiredTasks.Begin();
		prior_task_iter != pTask->m_RequiredTasks.End(); ++prior_task_iter)
	{
		if (!InsertToTaskList(rTaskInfoList, rTaskFuncList, rTaskStack, *prior_task_iter))
		{
			rTaskStack.Pop();
			return false;
		}
	}

	rTaskInfoList.Add(pTask);
	rTaskFuncList.Add(pTask->m_Func);
	rTaskStack.Pop();
	return true;
}
开发者ID:justinliew,项目名称:Helium,代码行数:65,代码来源:TaskScheduler.cpp

示例8: main

int main()
{
	DynamicArray da;

	//
	// 1: Добавяме елементи в масива
	//
	std::cout << "Adding numbers to the array: ";

	for(int i = 0; i < 10; i++)
	{
		
		da.Add(i);
		std::cout << i << ", ";
	}

	std::cout << "done\n\n";


	//
	// 2: Извеждаме елементите с помощта на оператора []
	//
	std::cout << "The array contains: " << da[0];

	for(size_t i = 1; i < da.GetLength(); i++)
	{
		std::cout << ", " << da[i];
	}

	std::cout << "\n\n";
	

	//
	// 3: Променяме елементите с помощта на оператора []
	//
	std::cout << "Multiplying each array element by 10...\n";

	for(size_t i = 0; i < da.GetLength(); i++)
	{
		// По-долу не можем да използваме оператора *=,
		// тъй като той не е дефиниран за DynamicArrayElementProxy
		// (въпреки, че можем да го направим, ако е нужно)
		da[i] = da[i] * 10;
	}

	da.Print();
	std::cout << "\n";


	//
	// 4: Опит за работа с константен масив
	//
	std::cout << "Let's go constant!\n";

	const DynamicArray & cda = da;

	std::cout << "The fifth element is " << cda[5] << "\n\n"; // този код е коректен...

	// ...но даденият в по-долния коментар няма да се компилира:
	// cda[5] = 10;


	//
	// 5: Опит за достъп до невалиден индекс
	//
	std::cout << "Trying to access an invalid index...\n";

	try
	{
		da.GetAt(da.GetLength() + 1);
	}
	catch(std::out_of_range& e)
	{
		std::cerr << "Exception caught: " << e.what() << std::endl;
	}

	return 0;
}
开发者ID:mariannavl,项目名称:sdp-samples,代码行数:78,代码来源:main.cpp


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