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


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

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


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

示例1:

typename T2::iterator copy_safe_apart(size_t n, const T1 & tab_src, T2 & tab_dst, size_t offset_src=0, size_t offset_dst=0) {
	_dbg5("copy (tab) n="<<n);
	if (n<1) return tab_dst.begin();

	// could write both blocks below with lambda, in C++17TODO when decomposition declarations is available

	// source
	auto src_rb = tab_src.begin() + offset_src; // rb = range begin
	_check_input( offset_src < tab_src.size() );
	_check_input( n <= tab_src.size() - offset_src ); // subtracting offset_src is valid since above
	auto src_rl = tab_src.begin() + offset_src + n -1; // range last
	_dbg5("Source     range src_rb="<<to_debug(src_rb)<<" ... src_rl="<<to_debug(src_rl));
	_check_abort( src_rl <= tab_src.end() );

	// dest
	auto dst_rb = tab_dst.begin() + offset_dst; // rb = range begin
	_check_input( offset_dst < tab_dst.size() );
	_check_input( n <= tab_dst.size() - offset_dst ); // subtracting offset_dst is valid since above
	auto dst_rl = tab_dst.begin() + offset_dst + n -1; // range last
	_dbg5("Destintion range dst_rb="<<to_debug(dst_rb)<<" ... dst_rl="<<to_debug(dst_rl));
	_check_abort( dst_rl <= tab_dst.end() );

	bool overlap = test_ranges_overlap_inclusive_noempty(src_rb, src_rl,  dst_rb, dst_rl);
	_dbg5("overlap=" << overlap);
	_check_input(!overlap);

	copy_iter_and_check_no_overlap( src_rb, src_rl,  dst_rb, n );
	_dbg5("Copy done.");

	return dst_rb;
}
开发者ID:robertoleksy,项目名称:galaxy42,代码行数:31,代码来源:tab.hpp

示例2: tensor_product

  inline void tensor_product(const T1& v1, const T2& v2, T3& m)
  {
    cf3_assert(m.getNbRows()    == v1.size());
    cf3_assert(m.getNbColumns() == v2.size());

    const Uint v1size = v1.size();
    const Uint v2size = v2.size();
    for (Uint i = 0; i < v1size; ++i) {
      for (Uint j = 0; j < v2size; ++j) {
        m(i,j) = v1[i]*v2[j];
      }
    }
  }
开发者ID:Peita,项目名称:coolfluid3,代码行数:13,代码来源:Functions.hpp

示例3: add

	void add(T1 from, T2 to, Lambda lambda) {
		if (from.empty() || to.empty())
			return;
		size_t iFrom = rand() % from.size();
		size_t iTo = rand() % to.size();
		lambda(iFrom, iTo);
	}
开发者ID:dima-murzin,项目名称:Seminars,代码行数:7,代码来源:main.cpp

示例4: deep_compare

void deep_compare( const T1& X, const T2& Y )
{
    BOOST_REQUIRE( X.size() == Y.size() );
    for( unsigned int nIndex=0; nIndex<X.size(); ++nIndex )
    {
        BOOST_CHECK( equals( X[nIndex], Y[nIndex] ) );
    }
}
开发者ID:PandaPYH,项目名称:boost-svn,代码行数:8,代码来源:split_test.cpp

示例5: binary_string_xor

T1 binary_string_xor(T1 const & str1, T2 const& str2) {
	// WARNING: this function is written with less assertive code (e.g. without at()),
	// it MUST be checked against any errors if you would modify it.
	const auto size1 = str1.size();
	const auto size2 = str2.size();
	if (size1 != size2) throw std::runtime_error(
		string("Can not execute function ")	+ string(__func__) + string(" because different size: ")
		+ std::to_string(size1) + " vs " + std::to_string(size2) );

	// this is safe also for locked string:
	T1 ret( str1 );
	for (size_t i=0; i<size1; ++i) ret[i] ^= str2[i];
	// TODO: decltype(size1) without const

	assert(ret.size() == str1.size());	assert(str1.size() == str2.size());
	return ret;
}
开发者ID:da2ce7,项目名称:antinet,代码行数:17,代码来源:crypto_basic.hpp

示例6: inner_product

  inline Real inner_product (const T1& v1, const T2& v2)
  {
    cf3_assert(v1.size() == v2.size());

    const Uint size = v1.size();
    Real result = 0.0;
    for (Uint i = 0; i < size; ++i)
      result += v1[i]*v2[i];
    return result;
  }
开发者ID:Peita,项目名称:coolfluid3,代码行数:10,代码来源:Functions.hpp

示例7: cross_product

  inline void cross_product (const T1& v1,
                             const T2& v2,
                             T3& result)
  {
    // sanity checks
    cf3_assert(v1.size() == 3);
    cf3_assert(v2.size() == 3);
    cf3_assert(result.size() == 3);

    result[0] =  v1[1]*v2[2] - v1[2]*v2[1];
    result[1] = -v1[0]*v2[2] + v1[2]*v2[0];
    result[2] =  v1[0]*v2[1] - v1[1]*v2[0];
  }
开发者ID:Peita,项目名称:coolfluid3,代码行数:13,代码来源:Functions.hpp

示例8: get_distance

  inline Real get_distance(const T1& n1, const T2& n2)
  {
    cf3_assert(n1.size() == n2.size());

    Real dist = 0.;
    const Uint size =  n1.size();
    for (Uint i = 0; i < size; ++i)
    {
      const Real diff = n1[i] - n2[i];
      dist += diff*diff;
    }
    return std::sqrt(dist);
  }
开发者ID:Peita,项目名称:coolfluid3,代码行数:13,代码来源:Functions.hpp

示例9: mixed_product

  inline Real mixed_product (const T1& v1,
                             const T2& v2,
                             const T3& v3,
                             T4& temp)
  {
    // sanity checks
    cf3_assert(v1.size() == 3);
    cf3_assert(v2.size() == 3);
    cf3_assert(v3.size() == 3);
    cf3_assert(temp.size() == 3);

    cross_product(v1, v2, temp);
    return inner_product(v3, temp);
  }
开发者ID:Peita,项目名称:coolfluid3,代码行数:14,代码来源:Functions.hpp

示例10: insertSort

void insertSort( T1& nums, T2& vecnum)
{
	for(auto lit = nums.begin(); lit!=nums.end(); lit++)
	{
		if(vecnum.size()==0) vecnum.push_back(*lit);
		else
		{
			auto vit = vecnum.begin(); //vector iterator
			while(*vit<*lit && vit!=vecnum.end())
				vit++;
			vecnum.insert(vit, *lit);
		}
	}
}
开发者ID:saniaarif22,项目名称:CPlusPlus,代码行数:14,代码来源:allSort.cpp

示例11: catch

template <typename T1, typename T2> void merge_exception_test(T1 x, T2 y)
{
    std::size_t size = x.size() + y.size();

    try {
        ENABLE_EXCEPTIONS;
        x.merge(y);
    } catch (...) {
        test::check_equivalent_keys(x);
        test::check_equivalent_keys(y);
        throw;
    }

    // Not a full check, just want to make sure the merge completed.
    BOOST_TEST(size == x.size() + y.size());
    if (y.size()) {
        BOOST_TEST(test::has_unique_keys<T1>::value);
        for (typename T2::iterator it = y.begin(); it != y.end(); ++it) {
            BOOST_TEST(x.find(test::get_key<T2>(*it)) != x.end());
        }
    }
    test::check_equivalent_keys(x);
    test::check_equivalent_keys(y);
}
开发者ID:,项目名称:,代码行数:24,代码来源:

示例12: decompress

        static bool decompress( T2 &buffer_out, const T1 &buffer_in )
        {
            static const bool verbose = false;

            size_t decompressed_size = fastlz_decompress( &buffer_in.at(0), buffer_in.size(), &buffer_out.at(0), buffer_out.size() );

            bool ret = ( decompressed_size == buffer_out.size() );

            if( verbose )
            {
//                std::cout << moon9::echo( ret, decompressed_size, buffer_out.size() );
            }

            return ret;
        }
开发者ID:shammellee,项目名称:moon9,代码行数:15,代码来源:compress.hpp


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