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


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

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


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

示例1: free

void parameter::free(ArrayType &vecParams)
{
	for (ArrayType::iterator iter = vecParams.begin(); iter != vecParams.end(); ++iter)
	{
		delete *iter;
	}
	vecParams.clear();
}
开发者ID:madsen-git,项目名称:NTools,代码行数:8,代码来源:dbtype.cpp

示例2: RearrangeArrayInPlace

auto RearrangeArrayInPlace(ArrayType elements) {
    for (ArrayType::size_type i = 0; i < elements.size(); ++i) {
        elements[elements[i] % elements.size()] += i * elements.size();
    }

    std::transform(elements.cbegin(), elements.cend(),
    elements.begin(), [&elements](const ArrayType::value_type v) {
        return v / elements.size();
    });

    return elements;
}
开发者ID:yyang-even,项目名称:algorithms,代码行数:12,代码来源:rearrange_array_arrj_becomes_i_if_arri_j.cpp

示例3: CreateWavefunctionEpetraMap

Epetra_Map_Ptr CreateWavefunctionEpetraMap(typename Wavefunction<Rank>::Ptr psi)
{
	typedef blitz::Array<cplx, Rank> ArrayType;
	

	ArrayType data = psi->GetData();
	typename DistributedModel<Rank>::Ptr distr = psi->GetRepresentation()->GetDistributedModel();
	Epetra_Comm_Ptr comm = CreateDistributedModelEpetraComm<Rank>(distr);

	int localSize = data.size();
	int* myElems = new int[localSize*2];

	//Get strides of the global Rank-dimensional array
	blitz::TinyVector<int, Rank> globalShape = psi->GetRepresentation()->GetFullShape();
	blitz::TinyVector<int, Rank> globalStrides;
	globalStrides(Rank-1) = 1;
	for (int rank=Rank-2; rank>=0; rank--)
	{
		globalStrides(rank) = globalStrides(rank+1)	* globalShape(rank+1);
	}

	//Get maps to global indices for each rank
	blitz::TinyVector<blitz::Range, Rank> globalIndices;
	for (int rank=0; rank<Rank; rank++)
	{
		globalIndices(rank) = distr->GetLocalIndexRange(globalShape(rank), rank);
	}
	
	typename blitz::Array<cplx, Rank>::iterator it = data.begin();
	for (int linearCount=0; linearCount<data.size(); linearCount++)
	{
		//Get global position for the current element
		int globalPos = 0;
		for (int rank=0; rank<Rank; rank++)
		{
			int rankPos = it.position()(rank);
			globalPos += globalStrides(rank) * globalIndices(rank)(rankPos);
		}

		//real component
		myElems[2*linearCount] = 2*globalPos;
		//imaginary component
		myElems[2*linearCount+1] = 2*globalPos + 1;
			
		++it;	
	}

	return Epetra_Map_Ptr( new Epetra_Map(-1, localSize*2, myElems, 0, *comm) );
}
开发者ID:AtomAleks,项目名称:PyProp,代码行数:49,代码来源:pyprop_epetra.cpp

示例4: ArrayComparisonFunctor

 /**
  * @brief   Construct an ArrayComparisonFunctor for an array.
  *
  * @param   array   Array to compare values against
  * @param   strict  Flag to use strict type comparison
  */
 ArrayComparisonFunctor(const ArrayType &array, bool strict)
   : itr(array.begin()),
     end(array.end()),
     strict(strict) { }
开发者ID:btolfa,项目名称:valijson,代码行数:10,代码来源:basic_adapter.hpp

示例5: CountInversionsMergeSort

auto CountInversionsMergeSort(ArrayType values) {
    return MergeSort(values.begin(), values.size());
}
开发者ID:yyang-even,项目名称:algorithms,代码行数:3,代码来源:count_inversions.cpp


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