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


C++ initializer_list::size方法代码示例

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


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

示例1: addCell

  // // //Add cell to the list
  void addCell(initializer_list<int_8 > l) {    
    if (l.size() == 2) {
      listCell.emplace_back( shared_ptr<Cell > (new Line(l)) ); 
 //     //listCell.emplace_back(shared_ptr<Cell > (new Line(tmp)) );
    } else if (l.size() == 3) {
  //     //listCell.emplace_back(shared_ptr<Cell > (new Tri(tmp)) ); 
    } else if (l.size() == 4) {
      listCell.emplace_back( shared_ptr<Cell > (new Quad(l)) ); 
    } else if (l.size() == 8) {
       //listCell.emplace_back( shared_ptr<Cell > (new Hexa(tmp)) ); 
    } else {
      cout << "Cell type not understood!"<<endl; 
      exit(1); 
    }
    nCellSize += l.size() + 1;
    auto c = *(listCell.rbegin()); 

    c->id = listCell.size()-1;
    c->grid = this; 
    c->assignCelltoNode();
    for (auto v: listVar) {
      if (v->loc == 0) {
	v->data.push_back(0); 
	v->data.uncompress();
      }
    }
    c->masterx.resize(levelHighBound[0]+1, false); 
    c->mastery.resize(levelHighBound[1]+1, false); 
    c->masterz.resize(levelHighBound[2]+1, false); 
  }
开发者ID:uzgoren,项目名称:girdap,代码行数:31,代码来源:Grid.hpp

示例2:

UnitCell::UnitCell(
	initializer_list<initializer_list<double>> latticeVectors,
	bool isOwner
) :
	StateSet(isOwner)
{
	unsigned int numCoordinates = latticeVectors.begin()->size();
	for(unsigned int n = 1; n < latticeVectors.size(); n++){
		TBTKAssert(
			(latticeVectors.begin()+n)->size() == numCoordinates,
			"UnitCell::UnitCell()",
			"Incmopatible coordinate dimensions. The first lattice"
			<< "vector has " << numCoordinates << " coordinates, "
			<< "while lattice vector " << n << " has "
			<< (latticeVectors.begin()+n)->size()
			<< " coordinates.",
			""
		);
	}

	for(unsigned int n = 0; n < latticeVectors.size(); n++){
		this->latticeVectors.push_back(vector<double>());

		const initializer_list<double> *latticeVector = (latticeVectors.begin() + n);
		for(unsigned int c = 0; c < latticeVector->size(); c++)
			this->latticeVectors.at(n).push_back(*(latticeVector->begin()+c));
	}
}
开发者ID:dafer45,项目名称:TBTK,代码行数:28,代码来源:UnitCell.cpp

示例3: Type

		Function(const char* name, const char* returns, initializer_list<char*> takes, const char* description) : Type(name) {
			this->takes = new char*[takes.size() + 1];
			int index = 0;
			for (auto i : takes) { this->takes[index++] = i; }
			this->takes[takes.size()] = 0;
			this->returns = returns;
			this->description = description;
		}
开发者ID:nestharus,项目名称:Notepad---vJASS,代码行数:8,代码来源:function.hpp

示例4: invalid_argument

EvenSequenceNum::EvenSequenceNum(initializer_list<double> args)
{
  if (args.size() % 2 != 0)
    throw invalid_argument(" initializer_list should contain even number of elements!");
  mSequence.reserve(args.size());
  for (auto value : args)  mSequence.push_back(value);
   //mSequence.insert(cend(mSequence), cbegin(args), cend(args)); // alternate to the above for loop
}
开发者ID:georgiosdoumas,项目名称:ProgrammingCplusplus-,代码行数:8,代码来源:EvenSequence.cpp

示例5:

Vector<T>::Vector(const initializer_list<T>& l) {
    static_assert(is_move_assignable<T>::value, "Type is not move assignable.");
    static_assert(is_move_constructible<T>::value, "Type is not move constructible."); // Can be constructed fr rvalue
    vectorsize = l.size();
    heap_size = l.size();
    array = new T[vectorsize];
    for (int i = 0; i < vectorsize; ++i) {
        array[i] = l.begin()[i];
    }
}
开发者ID:ninaolo,项目名称:hypercube,代码行数:10,代码来源:kth_cprog_template_container.hpp

示例6: Polynomial

    template<typename T> Polynomial(initializer_list<T> list){
        coeffs.resize(list.size());

        int i=list.size()-1;
        for(T t:list){
            coeffs[i]=t;
            i--;
        }

        reduce();
    }
开发者ID:OOliOO,项目名称:AlgGeom,代码行数:11,代码来源:polynomial.hpp

示例7: calc_histogram

/**
 * @brief calc_back_project : encapsulate calcHist, provide friendly api, all of the parameters meaning are same as
 * the calcHist
 */
void calc_histogram(initializer_list<Mat> images, OutputArray output, initializer_list<int> channels,
                    initializer_list<int> hist_sizes, initializer_list<float[2]> ranges,
InputArray mask, bool uniform, bool accumulate)
{
    size_t const sizes = ranges.size();
    vector<float const*> d_ranges(sizes);
    for(size_t i = 0; i != sizes; ++i){
        d_ranges[i] = *(begin(ranges) + i);
    }

    calcHist(begin(images), images.size(), begin(channels), mask, output,
                 channels.size(), begin(hist_sizes), &d_ranges[0], uniform ,accumulate);
}
开发者ID:hmouthier,项目名称:Traitement,代码行数:17,代码来源:histogram.cpp

示例8:

StateTreeNode::StateTreeNode(
	initializer_list<double> center,
	double halfSize,
	int maxDepth
) :
	numSpacePartitions(pow(2, center.size()))
{
	for(unsigned int n = 0; n < center.size(); n++)
		this->center.push_back(*(center.begin() + n));

	this->halfSize = halfSize;
	this->maxDepth = maxDepth;
}
开发者ID:dafer45,项目名称:TBTK,代码行数:13,代码来源:StateTreeNode.cpp

示例9: invalid_argument

    PointSequence(initializer_list<double> args)
    {
	cout << "size : " << args.size() << endl;
	if(args.size() % 2 != 0)
	{
	    throw invalid_argument("initializer_list should"
				   "contain even number of elements.");
	}

	for(auto iter = args.begin(); iter != args.end(); ++iter)
	{
	    mVecPoints.push_back(*iter);
	}
    }
开发者ID:cloudrain21,项目名称:study_room,代码行数:14,代码来源:InitializerListCtor.cpp

示例10: Vector

  Vector(initializer_list<_Tp> __li, const _Allocator& __a = _Allocator()) :
		alloc(__a), __size(0), __capacity(0) {
      buffer = alloc.allocate(__li.size());
      for (auto _list : __li)
        push_back(_list);
      __capacity = __size;
    }
开发者ID:nadaahmad,项目名称:stdVector,代码行数:7,代码来源:vector.cpp

示例11: foo

void foo(initializer_list<int> x)
{
    //static_assert(x.size()==2, "dd"); // decomment for bestemmie
    int arr[x.size()];
     arr[0] = 10;
    cout << arr[0] << endl;
}
开发者ID:CCJY,项目名称:coliru,代码行数:7,代码来源:main.cpp

示例12: computeHashes

static const pair<vector<string>, unordered_map<string, int> > computeHashes(initializer_list<const char *> names)
{
	pair <vector<string>, unordered_map<string, int> > result;

	result.first.reserve(names.size());
	for (const char *name : names) {
		result.first.emplace_back(name);
	}

	result.second.reserve(names.size());
	for(typeof(names.size()) i = 0; i < names.size(); i++) {
		result.second.emplace(result.first[i], i);
	}

	return result;
}
开发者ID:HAC2014,项目名称:hackerboat,代码行数:16,代码来源:enumtable.cpp

示例13: end

Model::Model(initializer_list<string> meshNames,
			 const string& diffuseName,
			 const string& specularName,
		 	 const string& ambientName,
		 	 const string& normalName,
		 	 float uniformScale,
			 float translateY,
			 float rotateY) {
	// Load meshes
	meshes.resize(meshNames.size());
	int i = 0;
	for (auto name : meshNames) {
		meshes[i].load(name);
		i += 1;
	}
	// Load textures
	diffuse.loadImage(diffuseName);
	specular.loadImage(specularName);
	if (useNormalMapping) {
		ambient.loadImage(ambientName);
		normal.loadImage(normalName);
		// Generate tangent values for normal mapping
		transform(begin(meshes), end(meshes), back_inserter(tangents), Model::generateTangents);
	}
	// Save scaling and translation values
	this->uniformScale = uniformScale;
	this->translateY = translateY;
	this->rotateY = rotateY;
}
开发者ID:danielmorena,项目名称:creepyportrait,代码行数:29,代码来源:Model.cpp

示例14: invalid_argument

	PointSequence(initializer_list<double> args)
	{
		if (args.size() % 2 != 0)
			throw invalid_argument("initializer_list should contain even number of elements.");
		for (auto iter = args.begin(); iter != args.end(); ++iter)
			mVecPoints.push_back(*iter);
	}
开发者ID:EmuxEvans,项目名称:Woody-Ye-s-Code-Share,代码行数:7,代码来源:InitializerListCtor.cpp

示例15: Vector

 Vector(initializer_list<T> list) : size{list.size()}
 {
     cout << "initializer list constructor" << endl;
     int i = 0;
     a.reset(new T[size]);
     for (auto iter = list.begin(); iter != list.end(); ++iter, ++i)
         a.get()[i] = *iter;
 }
开发者ID:QSaman,项目名称:CppExamples,代码行数:8,代码来源:Vector1.cpp


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