• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ container类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中container的典型用法代码示例。如果您正苦于以下问题:C++ container类的具体用法?C++ container怎么用?C++ container使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: bayesian_trainer

heuristic_trainer::heuristic_trainer(container & heuristic_word_files,
			super_container & file_names_by_subject,
			std::vector<std::string> & output_names)
				: bayesian_trainer(output_names) {

	//initialise the maps with the words
	container heuristic_words;
	probability_maps = std::list<word_map>(3);
	files_to_words(heuristic_word_files.begin(), heuristic_word_files.end(),
			std::back_inserter(heuristic_words));
	for(word_map & map : probability_maps) {
		std::for_each(heuristic_words.begin(), heuristic_words.end(),
				words_to_map(map));
	}

	// calculate n and vocab size and fill in the corpera containers
	corpera_by_subject = super_container(3);
	std::set<std::string> vocab_set;
	super_container::iterator corpera_it = corpera_by_subject.begin();
	for (container & subject : file_names_by_subject) {
		files_to_words(subject.begin(), subject.end(),
				std::back_inserter<container>(*corpera_it));
		vocab_set.insert<container::iterator>(corpera_it->begin(), corpera_it->end());
		++corpera_it;
	}
}
开发者ID:dpshorten,项目名称:bayesian_backup,代码行数:26,代码来源:heuristic_trainer.cpp


示例2: hex_to_binary

    static
    void
    hex_to_binary (fwditer first, fwditer last, container& out)
    {
        struct table
        {
            int val[256];
            table ()
            {
                std::fill (val, val+256, 0);
                for (int i = 0; i < 10; ++i)
                    val ['0'+i] = i;
                for (int i = 0; i < 6; ++i)
                {
                    val ['a'+i] = 10 + i;
                    val ['a'+i] = 10 + i;
                }
            }
            int operator[] (int i)
            {
               return val[i];
            }
        };

        static table lut;
        out.reserve (std::distance (first, last) / 2);
        while (first != last)
        {
            auto const hi (lut[(*first++)]);
            auto const lo (lut[(*first++)]);
            out.push_back ((hi*16)+lo);
        }
    }
开发者ID:moorecoin,项目名称:MooreCoinService,代码行数:33,代码来源:ECDSACanonical.test.cpp


示例3: insert

	void insert(It b, It e) {
		size_t d = std::distance(b, e);
		if (d == 1) {
			insert(*b);
			return;
		}

		static container merged;
		merged.resize(0);
		merged.reserve(elements.size() + d);

		if (detail::is_sorted(b, e, comp)) {
			std::merge(elements.begin(), elements.end(), b, e, std::back_inserter(merged), comp);
		}
		else {
			static container sorted;
			sorted.assign(b, e);
			std::sort(sorted.begin(), sorted.end(), comp);
			std::merge(elements.begin(), elements.end(), sorted.begin(), sorted.end(), std::back_inserter(merged), comp);
		}

		merged.swap(elements);
		iterator it = std::unique(elements.begin(), elements.end());
		elements.erase(it, elements.end());
	}
开发者ID:estnltk,项目名称:estnltk-vislcg3,代码行数:25,代码来源:sorted_vector.hpp


示例4: make_vector_zeroes

void make_vector_zeroes( container & vec, const typename container::size_type & d1)
{
	vec.resize(d1);
	for(auto it=vec.begin(); it!=vec.end(); ++it)
	{
		set_zero(*it);
	}
}
开发者ID:brgillis,项目名称:Magnification_Public,代码行数:8,代码来源:make_vector.hpp


示例5: make_vector_default

void make_vector_default( container & vec, const typename container::size_type & d1, const typename container::size_type & d2, Args... remaining_dims)
{
	vec.clear();
	vec.resize(d1);
	for(auto it=vec.begin(); it!=vec.end(); ++it)
	{
		make_vector_default(*it, d2, remaining_dims...);
	}
}
开发者ID:brgillis,项目名称:Magnification_Public,代码行数:9,代码来源:make_vector.hpp


示例6: matrix

 matrix(size_type N, size_type M, container<T> vector)
 : vec(N * M),
   rows(N),
   columns(M)
 {
     if (vector.size() == N * M) {
         std::copy(vector.begin(), vector.end(), vec.begin());
     }
 }
开发者ID:makramkd,项目名称:qr-decomposition,代码行数:9,代码来源:matrix.hpp


示例7: vector_valuer

	vector_valuer(container & vec, const value_type & val, const other_container & other_vec)
	{
		vec.resize(other_vec.size());
		auto o_it = other_vec.begin();

		for(auto it=vec.begin(); it!=vec.end(); ++it)
		{
			vector_valuer<d-1,decltype(*it),value_type,decltype(*o_it)>(*it,val,*o_it);
		}
	}
开发者ID:brgillis,项目名称:Magnification_Public,代码行数:10,代码来源:make_vector.hpp


示例8: vector_defaulter

	vector_defaulter(container & vec, const other_container & other_vec)
	{
		vec.resize(other_vec.size());
		auto o_it = other_vec.begin();

		for(auto it=vec.begin(); it!=vec.end(); ++it)
		{
			vector_defaulter<d-1,decltype(*it),decltype(*o_it)>(*it,*o_it);
		}
	}
开发者ID:brgillis,项目名称:Magnification_Public,代码行数:10,代码来源:make_vector.hpp


示例9: Join

inline string Join(const string& delim, const container& c) 
{
	ostringstream ret;
	typedef typename container::const_iterator iterator;
	for( iterator q = c.begin(); q != c.end(); ++q ) {
		if( q != c.begin() ) ret << delim;
		ret << *q;
	}
	return ret.str();
}
开发者ID:DmitrySigaev,项目名称:ncbi,代码行数:10,代码来源:string-util.hpp


示例10: v

 boost::python::list
 multimap_algorithms<ContainerTraits, Ovr>::get (container &c, index_param ix)
 {
   boost::python::list l;
   typedef BOOST_DEDUCED_TYPENAME container::iterator iter_type;
   for( iter_type index = c.lower_bound( ix ); index != c.upper_bound( ix ); ++index ){
       boost::python::object v( index->second );
       l.append( v );
   }
   return l;
 }
开发者ID:CTrauma,项目名称:pypp11,代码行数:11,代码来源:multimap.hpp


示例11: _func

Country Countries::find(const Key &_k,
						SetFunc &_func,
						const container&_container)const{

	Country c;
	_func(c, _k);
	auto iter = _container.find(c);
	if (iter != _container.end())
		return *iter;
	return Country();
}
开发者ID:PrakaramJoshi,项目名称:Common,代码行数:11,代码来源:Country.cpp


示例12: make_vector_function

void make_vector_function( container & vec, const func_type & func, const typename container::size_type & d1)
{
	vec.clear();
	vec.reserve(d1);

	typename container::size_type i(0);

	for(i=0; i<d1; ++i)
	{
		vec.push_back(func(i));
	}
}
开发者ID:brgillis,项目名称:Magnification_Public,代码行数:12,代码来源:make_vector.hpp


示例13: print

template <template <class> class container, class T> void print(container<T>& vec)
{
  printf("vector - size(%u) capacity(%u)\n", vec.size(), vec.capacity());

  for (auto it = vec.begin(); it != vec.end(); ++it)
    print(*it);
  
  //test const version
  printf("test const version\n");
  const container<T>& const_vec = vec;
  for (auto it : vec)
    print(it);
}
开发者ID:antlhuede,项目名称:Spring-2014,代码行数:13,代码来源:test_containers.cpp


示例14: vector_zeroer

	vector_zeroer(container & vec, const other_container & other_vec)
	{
		if(!other_vec.empty())
		{
			vec.resize(1);
			set_zero(vec.front());
			vec.resize(other_vec.size(),vec.front());
		}
		else
		{
			vec.resize(0);
		}
	}
开发者ID:brgillis,项目名称:Magnification_Public,代码行数:13,代码来源:make_vector.hpp


示例15: verify_dest

 void verify_dest(const std::string& cmd_dest, container& backup_dir) {
   
   if (not is_remote(cmd_dest)) {
     fs::path dest_dir(fs::initial_path());
     dest_dir = fs::system_complete(fs::path(cmd_dest, fs::native));
     backup_dir.destination(dest_dir.native_file_string());
     if (not fs::exists(dest_dir)) throw Backup::Error::Directory_Error("Destination directory does not exist!");
     if (not fs::is_directory(dest_dir)) throw Backup::Error::Directory_Error("Destination specified is not a directory!");
   }
   else {
     backup_dir.destination(cmd_dest);
   }
 }
开发者ID:PJames,项目名称:oklibrary,代码行数:13,代码来源:Path_Loader.hpp


示例16: insert

void insert(container& c, int key, int val)
{
	auto itr = c.insert(make_pair(key,val));
	if(!itr.second)
	{
		cout << "re-insert " << "[" << key << "," << val << "]" << "!!!" << endl;
#if 0
		c.erase(itr.first);
		c.insert(make_pair(key,val));
#else
		itr.first->second = val;
#endif
	}
}
开发者ID:rahul-deshmukhpatil,项目名称:Notes-and-Docs,代码行数:14,代码来源:isert.cpp


示例17: copy

void container::copy(size_t i, container const &other, size_t l, size_t r)
{
    if (r <= l)
        throw std::invalid_argument(
                "big_integer: container: in function copy(): left bound is larger than the right one"
        );

    if (r - l == 1 && sz == 0) {
        sz = 1;
        data_short = *(other.data_long->begin() + l);
        return;
    }

    if (sz == 1)
        data_long = std::make_shared< std::vector<uint32_t> > (1, data_short);
    else
        real_copy();

    if (other.size() == 1)
        data_long->insert(data_long->begin() + i, other.data_short);
    else
        std::copy(other.data_long->begin() + l,
                  other.data_long->begin() + r,
                  this->data_long->begin() + i
        );

    sz = data_long->size();
}
开发者ID:StasyaGera,项目名称:cpp-course,代码行数:28,代码来源:container_v1.cpp


示例18: vector_functioner

	vector_functioner(container & vec, const func_type & func, const other_container & other_vec)
	{
		const typename container::size_type i;
		auto new_func = [&] (Args... args)
		{
			return func(i,args...);
		};

		vec.clear();
		vec.reserve(other_vec.size());
		for(i=0; i<other_vec.size(); ++i)
		{
			vector_functioner<d-1,decltype(vec[i]),decltype(new_func),decltype(other_vec[i])>
				(vec[i],new_func,other_vec[i]);
		}
	}
开发者ID:brgillis,项目名称:Magnification_Public,代码行数:16,代码来源:make_vector.hpp


示例19: find_variable_names

 static std::set<core::identifier_string> find_variable_names(const container& equations)
 {
   std::set<pbes_system::propositional_variable_instantiation> occ;
   auto oit = std::inserter(occ, occ.end());
   std::set<core::identifier_string> occ_ids;
   for(auto it = equations.begin(); it != equations.end(); ++it)
   {
     pbes_system::detail::make_find_propositional_variables_traverser<pbes_system::pbes_expression_traverser>(oit).apply(it->formula());
     occ_ids.insert(it->variable().name());
   }
   for(auto it = occ.begin(); it != occ.end(); ++it)
   {
     occ_ids.insert(it->name());
   }
   return occ_ids;
 }
开发者ID:gijskant,项目名称:mcrl2-pmc,代码行数:16,代码来源:cwi.cpp


示例20: verify_source

 void verify_source(const std::string& cmd_source, container& backup_dir) {
   fs::path source_dir(fs::initial_path());
   source_dir = fs::system_complete(fs::path(cmd_source, fs::native));
   backup_dir.source(source_dir.native_file_string());
   if (not fs::exists(source_dir)) throw Backup::Error::Directory_Error("Source directory does not exist!");      
   if (not fs::is_directory(source_dir)) throw Backup::Error::Directory_Error("Source specified is not a directory!");
   if (fs::is_empty(source_dir)) throw Backup::Error::Directory_Error("Source directory is empty!");
 }
开发者ID:PJames,项目名称:oklibrary,代码行数:8,代码来源:Path_Loader.hpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ container_t类代码示例发布时间:2022-05-31
下一篇:
C++ const_string_set_t类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap