本文整理汇总了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);
}
}
示例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;
}