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


C++ Cont类代码示例

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


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

示例1: zip_var

auto zip_var(LastCont lastContainer) {
  Cont<tuple<typename LastCont::value_type>, allocator<tuple<typename LastCont::value_type>>> result;
  for_each(lastContainer.begin(), lastContainer.end(), [&](auto &content) {
    result.insert(result.end(), make_tuple(content));
  });
  return result;
}
开发者ID:Axure,项目名称:Curious-C--Facilities,代码行数:7,代码来源:main.cpp

示例2: test_serialization_helper

void test_serialization_helper()
{
    Cont vec;
    add( vec, new Base( -1 ), 0u );
    add( vec, new Derived( 1 ), 1u );

    std::ofstream ofs("filename");
    boost::archive::text_oarchive oa(ofs);
    oa << as_const(vec);
    ofs.close();

    
    
    std::ifstream ifs("filename", std::ios::binary);
    boost::archive::text_iarchive ia(ifs);
    Cont vec2;
    ia >> vec2;
    ifs.close();

    BOOST_CHECK_EQUAL( vec.size(), vec2.size() );
    BOOST_CHECK_EQUAL( (*vec2.begin()).i, -1 );
    BOOST_CHECK_EQUAL( (*--vec2.end()).i, 0 );
    typename Cont::iterator i = vec2.end();
    --i;
    Derived* d = dynamic_cast<Derived*>( &*i ); 
    BOOST_CHECK_EQUAL( d->i2, 1 );
}
开发者ID:KerwinMa,项目名称:AerothFlyffSource,代码行数:27,代码来源:serialization.cpp

示例3: insert

	bool insert(T t) {
		ContIter it = std::lower_bound(elements.begin(), elements.end(), t);
		if (it != elements.end() && t >= it->lb && t <= it->ub) {
			return false;
		}
		ContIter pr = it - 1;
		if (it != elements.begin() && pr->ub + 1 == t) {
			++pr->ub;
			if (it != elements.end() && pr->ub + 1 == it->lb) {
				pr->ub = it->ub;
				elements.erase(it);
			}
		}
		else if (it != elements.end() && it->lb == t + 1) {
			--it->lb;
			if (it != elements.begin() && pr->ub + 1 == it->lb) {
				pr->ub = it->ub;
				elements.erase(it);
			}
		}
		else {
			elements.insert(it, interval(t));
		}
		++_size;
		return true;
	}
开发者ID:estnltk,项目名称:estnltk-vislcg3,代码行数:26,代码来源:interval_vector.hpp

示例4:

//---------------------------------------------------------------------------
void    Graph::Visit(int From, Cont & C)
{
	if (From >= 0 && From < _Size)
	{
		int V = From;
		bool * Labelled = new bool[_Size];
		for(int i = 0; i < _Size; i++)
			Labelled[i] = false;
		C.Push(V);
		Labelled[V] = true;
		do
		{
			V = C.Pop();
			printf("%d ", V);
			for(int U = 0; U < _Size; U++)
			{
				if(!Labelled[U] && _m[V][U] != MAXDOUBLE)
				{
					C.Push(U);
					Labelled[U] = true;
				}
			}
		}
		while(!C.Empty());
		delete [] Labelled;
		printf("\n");
	}
}
开发者ID:ingver,项目名称:dsa-labs,代码行数:29,代码来源:graph.cpp

示例5: insert_back

void insert_back(Cont& c, long& avg, const int& num_op)
{
	cout << "\nCounting..." 
		<< "time of " << num_op << " back_insert";
	clock_t t = 0;

	for(int j = 0; j < REPEAT_TEST; ++j)
	{

		c.push_back(0);
		c.push_back(0);

		auto it = c.end();
		t = clock();
		for (int i = 1; i <= num_op ; ++i)
		{
			it = c.end();
			c.insert(it, i);		
		}

		t = clock() - t;
		avg += t;
		c.clear();
	}


	avg /= REPEAT_TEST;
}
开发者ID:OlexandrSavchuk,项目名称:cpp-lessons,代码行数:28,代码来源:cmpContainers.cpp

示例6: intersect

	interval_vector intersect(const interval_vector& o) const {
		interval_vector rv;
		if (!empty() && !o.empty()) {
			ContConstIter a = elements.begin();
			ContConstIter b = o.elements.begin();
			while (a != elements.end() && b != o.elements.end()) {
				while (a != elements.end() && b != o.elements.end() && a->ub < b->lb) {
					++a;
				}
				while (a != elements.end() && b != o.elements.end() && b->ub < a->lb) {
					++b;
				}
				while (a != elements.end() && b != o.elements.end() && a->ub >= b->lb && b->ub >= a->lb) {
					const T lb = std::max(a->lb, b->lb);
					const T ub = std::min(a->ub, b->ub);
					if (!rv.elements.empty() && rv.elements.back().ub + 1 == lb) {
						rv.elements.back().ub = ub;
					}
					else {
						rv.elements.push_back(interval(lb, ub));
					}
					rv._size += ub - lb + 1;
					if (a->ub < b->ub) {
						++a;
					}
					else {
						++b;
					}
				}
			}
		}
		return rv;
	}
开发者ID:estnltk,项目名称:estnltk-vislcg3,代码行数:33,代码来源:interval_vector.hpp

示例7: erase

	bool erase(T t) {
		ContIter it = std::lower_bound(elements.begin(), elements.end(), t);
		if (it == elements.end()) {
			return false;
		}
		if (it->ub < t || it->lb > t) {
			return false;
		}
		if (it->lb == t && it->ub == t) {
			elements.erase(it);
			--_size;
			return true;
		}
		if (it->ub == t) {
			--it->ub;
			--_size;
			return true;
		}
		if (it->lb == t) {
			++it->lb;
			--_size;
			return true;
		}
		if (it->lb < t && it->ub > t) {
			elements.insert(it + 1, interval(t + 1, it->ub));
			it->ub = t - 1;
			--_size;
			return true;
		}

		assert(false && "interval_vector.erase() should never reach this place...");
		return false;
	}
开发者ID:estnltk,项目名称:estnltk-vislcg3,代码行数:33,代码来源:interval_vector.hpp

示例8: operator

 void operator()(Cont& c, long count) {
     long cnt = count / 100;
     for (long i = 0; i < cnt; i++) {
         typename Cont::iterator it = c.begin(),
                                      end = c.end();
         while (it != end) it++;
     }
 }
开发者ID:finalx,项目名称:finalx-labs-all,代码行数:8,代码来源:SequencePerformance.cpp

示例9: backInsertion

template<class Cont> void backInsertion(Cont& ci) {
  copy(a, a + sizeof(a)/sizeof(Cont::value_type),
    back_inserter(ci));
  copy(ci.begin(), ci.end(),
    ostream_iterator<typename Cont::value_type>(
    cout, " "));
  cout << endl;
}
开发者ID:BigR-Lab,项目名称:CodeRes_Cpp,代码行数:8,代码来源:Inserters.cpp

示例10: dump

void dump(Cont & container)
{
    for (ContIter iter = container.begin(); iter != container.end(); iter++)
    {
        cout << *iter << " ";
    }
    cout << endl;
}
开发者ID:mdaughtrey,项目名称:personal-projects,代码行数:8,代码来源:main.cpp

示例11: apply

void apply(Cont& c, PtrMemFun f) {
    typename Cont::iterator it = c.begin();
    while (it != c.end()) {
        //(it->*f)(); // Compact form //! gcc-4.4 gcc-4.6 ±àÒ벻ͨ¹ý
        ((*it).*f)(); // Alternate form
        it++;
    }
}
开发者ID:jacob-zhoupeng,项目名称:thinkincpp,代码行数:8,代码来源:Apply.cpp

示例12: hash_container_object

typename std::enable_if<is_hashable<typename Cont::value_type>::value, void>::type
hash_container_object(const Cont & cont, Hasher & hasher)
{
    // some containers don't have size() (ie, forward_list)
    size_t d = static_cast<size_t>(std::distance(cont.begin(), cont.end()));
    hasher(d);

    for(const auto & it : cont)
        hasher(it);
}
开发者ID:bennybp,项目名称:BPHash,代码行数:10,代码来源:ContainerHelper.hpp

示例13: midInsertion

void midInsertion(Cont& ci) {
    typename Cont::iterator it = ci.begin();
    it++;
    it++;
    it++;

    copy(a, a + sizeof(a)/(sizeof(int)*2), inserter(ci, it));
    copy(ci.begin(), ci.end(), ostream_iterator<int>(cout, " "));
    cout << endl;
}
开发者ID:jacob-zhoupeng,项目名称:thinkincpp,代码行数:10,代码来源:Inserters.cpp

示例14: contains

	bool contains(T t) const {
		ContConstIter it = std::lower_bound(elements.begin(), elements.end(), t);
		if (it == elements.end()) {
			return false;
		}
		if (it->ub < t || it->lb > t) {
			return false;
		}
		return true;
	}
开发者ID:estnltk,项目名称:estnltk-vislcg3,代码行数:10,代码来源:interval_vector.hpp

示例15: insert

	iterator insert(value_type&& val) {
		if (container.empty()) {
			return container.insert(cend(), val);
		}
		auto elementgreaterthanorequalto = std::lower_bound(cbegin(), cend(), val, std::ref(compare_predicate));
		return container.insert(elementgreaterthanorequalto, std::move(val));
	}
开发者ID:ThePhD,项目名称:lua-bench,代码行数:7,代码来源:ordered.hpp


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