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


C++ DynArray::begin方法代码示例

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


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

示例1: GetInputActor

void CFlashUIGetCompatibleAccessoriesNode ::ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo )
{
	if(event == eFE_Activate && IsPortActive(pActInfo, 0))
	{
		string accessories = "";
		IActor* pActor = GetInputActor( pActInfo );

		if(pActor)
		{
			IInventory* pInventory = pActor->GetInventory();
			if(pInventory)
			{
				//Get the item ID via the Input string
				const string weapon_name = GetPortString(pActInfo, eI_Weapon);
				IEntityClassRegistry *pRegistery = gEnv->pEntitySystem->GetClassRegistry();
				EntityId item = pInventory->GetItemByClass(pRegistery->FindClass(weapon_name));

				//Fetch the actual weapon via the ID
				IEntity* pEntity = gEnv->pEntitySystem->GetEntity(item);
				if(pEntity)
				{

					CGameObject * pGameObject = (CGameObject*)pEntity->GetProxy(ENTITY_PROXY_USER);
					const char* ext = pGameObject->GetEntity()->GetClass()->GetName();
					CWeapon* pWeapon = (CWeapon*)pGameObject->QueryExtension(pGameObject->GetEntity()->GetClass()->GetName());

					//If the weapon exists, ask for all compatible accessories
					if(pWeapon)
					{
						//All compatible accessories for this weapon
						const DynArray<string> pCompatibleAccessoriesVec = pWeapon->GetCompatibleAccessories();

						bool first = true;
						DynArray<string>::const_iterator it;
						for (it = pCompatibleAccessoriesVec.begin(); it != pCompatibleAccessoriesVec.end(); it++)
						{
							if (!first)
								accessories.append(",");
							accessories.append((*it));
							first = false;
						}
					}
				}
			}
		}

		//return, if 'accessories' is empty, it has no compatible attachments, or the weapon/inventory was invalid
		ActivateOutput(pActInfo, eO_OnCall, true);
		ActivateOutput(pActInfo, eO_Args, accessories);
	}
}
开发者ID:PiratesAhoy,项目名称:HeartsOfOak-Core,代码行数:51,代码来源:FlowWeaponCustomizationNodes.cpp

示例2: mpi_type

static std::unique_ptr<DynArray<MPIMsgT>> gather_msg_array(
MPI_Comm comm,
int root,		// The root rank
DynArray<MPIMsgT> &sbuf,		// Source buffer (msg on this MPI node)
int nfields,		// # of fields in MPIMsgT
int nele_l,					// # slots in source buffer
int nele_r_extra = 0)		// # extra slots to allocate in receive buffer
{
	int rank;
	MPI_Comm_rank(comm, &rank);

	// Gather buffers on root node
	int num_mpi_nodes;
	MPI_Comm_size(comm, &num_mpi_nodes); 

	// MPI_Gather the count
	std::unique_ptr<int[]> rcounts;
	rcounts.reset(new int[num_mpi_nodes]);
	for (int i=0; i<num_mpi_nodes; ++i) rcounts[i] = 0;

	MPI_Gather(&nele_l, 1, MPI_INT, &rcounts[0], 1, MPI_INT, root, comm);

	// Compute displacements as prefix sum of rcounts
	std::unique_ptr<int[]> displs;
	std::unique_ptr<DynArray<MPIMsgT>> rbuf;

	displs.reset(new int[num_mpi_nodes+1]);
	displs[0] = 0;
	for (int i=0; i<num_mpi_nodes; ++i) displs[i+1] = displs[i] + rcounts[i];
	int nele_g = displs[num_mpi_nodes];

	// Create receive buffer, and gather into it
	// (There's an extra item in the array for a sentinel)
	rbuf.reset(new DynArray<MPIMsgT>(sbuf.ele_size, nele_g+nele_r_extra));

	MPI_Datatype mpi_type(MPIMsgT::new_MPI_struct(nfields));
	MPI_Gatherv(sbuf.begin().get(), sbuf.size, mpi_type,
		rbuf->begin().get(), &rcounts[0], &displs[0], mpi_type,
		root, comm);
	MPI_Type_free(&mpi_type);


	return rbuf;
}
开发者ID:seifer08ms,项目名称:icebin,代码行数:44,代码来源:mpi.hpp


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