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


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

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


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

示例1: fromColors

CachedPalette CachedPalette::fromColors(std::initializer_list<Color>v) {
  CachedPalette pal(v.size());
  auto it = v.begin();
  for (int i = 0; i < pal.levels(); i++)
    pal[i] = *(it++);
  return pal;
}
开发者ID:axnjaxn,项目名称:libbyteimage,代码行数:7,代码来源:palette.cpp

示例2: test

void test ( const std::initializer_list<T> &vals ) {
    typedef std::dynarray<T> dynA;
    
    dynA d1 ( vals );
    assert ( d1.size () == vals.size() );
    assert ( std::equal ( vals.begin (), vals.end (), d1.begin (), d1.end ()));
    }
开发者ID:WizTeam,项目名称:llvm-project,代码行数:7,代码来源:default.pass.cpp

示例3: nr

Matrix::Matrix(std::initializer_list<double> v) : nr(v.size()), nc(1) {
  data = new double [nr];

  int i = 0;
  for (double d : v)
    data[i++] = d;
}
开发者ID:axnjaxn,项目名称:libbyteimage,代码行数:7,代码来源:matrix.cpp

示例4: setHeader

	bool setHeader(std::initializer_list<std::string> list) {
		if (list.size() != Columns) {
			return false;
		}
		header.insert(header.begin(), list);
		return true;
	}
开发者ID:Chris--B,项目名称:Parallel,代码行数:7,代码来源:Table.hpp

示例5: comb

double comb(std::initializer_list<double> values) {
    double sum = 0.0;
    for (double value: values) {
        sum += value;
    }
    return (sum/values.size());
}
开发者ID:songhtdo,项目名称:vespa,代码行数:7,代码来源:text_similarity_feature_test.cpp

示例6:

void		IGraphicObject::mFunction_AddVertices2D(NOISE_GRAPHIC_OBJECT_TYPE buffType, std::initializer_list<NVECTOR2> vertexList, std::initializer_list<NVECTOR4> colorList, std::initializer_list<NVECTOR2> texcoordList)
{

	N_SimpleVertex tmpVertex;
	auto vertexIter = vertexList.begin();
	auto colorIter = colorList.begin();
	auto texcoordIter = texcoordList.begin();

	//construct a N_SimpleVertex
	for (UINT i = 0;i < vertexList.size();i++)
	{

		tmpVertex = 
		{
			NVECTOR3(vertexIter->x+m_pBaseScreenSpacePosOffset->x,vertexIter->y + m_pBaseScreenSpacePosOffset->y,0.0f),
			*colorIter++,
			*texcoordIter++
		};
		vertexIter++;

		m_pVB_Mem[buffType]->push_back(tmpVertex);
	}

	//now it is allowed to update because of modification
	mCanUpdateToGpu[buffType] = TRUE;
}
开发者ID:CHINA-JIGE,项目名称:Noise3D-DirectX11,代码行数:26,代码来源:N2D_GraphicObject.cpp

示例7: qDebug

ProtocolDescriptorTestNode::ProtocolDescriptorTestNode(QString name, std::initializer_list<ProtocolDescriptorTestNode> init) {
    qDebug() << "*** CONSTRUCTOR CALLED - 2 *** ";
    qDebug() << init.size();
    for(ProtocolDescriptorTestNode x : init) {
        qDebug() << x.name << x.id;
    }
}
开发者ID:CCJY,项目名称:coliru,代码行数:7,代码来源:main.cpp

示例8: map

Set<T>::Set(std::initializer_list<T> args) : map()
{
  reserve(args.size());
  for (const auto &elm : args) {
    insert(elm);
  }
}
开发者ID:netromdk,项目名称:cods,代码行数:7,代码来源:Set.hpp

示例9: count

UIntVector::UIntVector(const std::initializer_list<unsigned int>& list) : count(list.size()), max_size(1 << static_cast<int>(ceil(log2(count)))), data(new unsigned int[max_size]) {
  size_t i;
  std::initializer_list<unsigned int>::iterator item;
  for(i = 0, item = list.begin(); item != list.end(); ++i, ++item) {
    data[i] = *item;
  }
}
开发者ID:ZetaTwo,项目名称:dd2387-laborationer,代码行数:7,代码来源:kth_cprog_simple_container.hpp

示例10: malloc

// Constructor with initializer list
DNA::DNA(const std::initializer_list<unsigned char> inputList) {
    dataSize = inputList.size();

    // Initialize genes
    dataGenes = (unsigned char*) malloc(dataSize * sizeof(unsigned char));
    std::memcpy(dataGenes, inputList.begin(), dataSize);
}
开发者ID:maleadt,项目名称:genetic,代码行数:8,代码来源:dna.cpp

示例11: format

std::string format(const char* fmt, std::initializer_list<Printable> values)
{
    std::stringstream ss;
    while (*fmt) {
        auto next = strchr(fmt, '%');

        // emit the rest of the format string if there are no more percents
        if (!next) {
            ss << fmt;
            break;
        }

        // emit everything up to the next percent
        ss.write(fmt, next - fmt);
        ++next;
        REALM_ASSERT(*next);

        // %% produces a single escaped %
        if (*next == '%') {
            ss << '%';
            fmt = next + 1;
            continue;
        }
        REALM_ASSERT(isdigit(*next));

        // The const_cast is safe because stroul does not actually modify
        // the pointed-to string, but it lacks a const overload
        auto index = strtoul(next, const_cast<char**>(&fmt), 10) - 1;
        REALM_ASSERT(index < values.size());
        (values.begin() + index)->print(ss);
    }
    return ss.str();
}
开发者ID:1037390459,项目名称:realm-cocoa,代码行数:33,代码来源:format.cpp

示例12: runtime_error

std::shared_ptr<cainteoir::buffer> zip_archive::read(const char *aFilename) const
{
	std::string filename = aFilename;
	auto entry = data.find(filename);
	if (entry == data.end())
	{
		size_t pos = 0;
		while ((pos = filename.find("%20", pos)) != std::string::npos)
		{
			filename.replace(pos, 3, " ");
			++pos;
		}
		entry = data.find(filename);
	}
	if (entry == data.end())
		return std::shared_ptr<cainteoir::buffer>();

	const zip_data &item = entry->second;
	if (item.cached) return item.cached;

	auto decoder = *(zip_compression.begin() + item.compression_type);
	if (item.compression_type >= zip_compression.size() || decoder == nullptr)
		throw std::runtime_error(i18n("decompression failed (unsupported compression type)"));

	cainteoir::buffer compressed { item.begin, item.begin + item.compressed };

	return const_cast<zip_data &>(item).cached = decoder(compressed, item.uncompressed);
}
开发者ID:ming-hai,项目名称:cainteoir-engine,代码行数:28,代码来源:zip.cpp

示例13:

	// Set with initializer list
	Set(const std::initializer_list<value_type>& l) {
		_set.reserve(l.size());
		
		for (const auto& value : l) {
			insert(value);
		}
	}
开发者ID:aseprano,项目名称:Set,代码行数:8,代码来源:Set.hpp

示例14: Node

BinTree::BinTree(std::initializer_list<int> inlist)
{
	if (inlist.size()==0) return;
	root = new Node(*inlist.begin());
	for (auto& el : inlist)
		insert(el);
}
开发者ID:Yanpas,项目名称:bintree,代码行数:7,代码来源:bintree.cpp

示例15: array

Vector<T>::Vector(const std::initializer_list<T> args) : size_array(args.size()), cap_array(args.size()*2), array(new T[cap_array]) {
	int i = 0;
	for (auto iter = args.begin(); iter != args.end(); ++iter) {
		array[i] = *iter;
		++i;
	}
}
开发者ID:lovelaze,项目名称:cpp,代码行数:7,代码来源:kth_cprog_template_container.hpp


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