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


C++ std::end方法代码示例

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


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

示例1: includes

	bool includes(anaset const &subset) const {
		using std::begin;
		using std::end;
		return subset.size() <= size() && std::equal(begin(letters),end(letters),
				           begin(subset.letters),end(subset.letters),
				[](unsigned char l,unsigned char r){ return l>=r;});
	}
开发者ID:PeterSommerlad,项目名称:CPlusPlusLecture,代码行数:7,代码来源:anagram_multiword_opt.cpp

示例2:

void
ModuleInstance::jump(const Label& label,
					 const CLOCK_INTERNAL_TYPE& elapsedTime,
					 Traial& traial) const
{
#ifndef NDEBUG
	if (!sealed_)
		throw_FigException("this module hasn't been sealed yet");
#endif
	assert(label.is_output());
	const auto iter = transitions_by_label_.find(label.str);
    // Foreign labels and taus won't touch us
    if (!label.is_tau() && end(transitions_by_label_) != iter) {
        const auto& transitions = iter->second;
		for (const Transition& tr: transitions) {
			if (tr.pre(traial.state)) { // If the traial satisfies this precondition
				tr.pos(traial.state);   // apply postcondition to its state
				tr.handle_clocks(       // and update clocks according to it.
					traial,
					begin(lClocks_),
					end(lClocks_),
					firstClock_,
					elapsedTime);
                return;  // At most one transition could've been enabled, trust Raúl
            }
       }
    }
    // No transition was enabled? Then just advance all clocks
	traial.kill_time(firstClock_, num_clocks(), elapsedTime);
}
开发者ID:raulmonti,项目名称:FIG,代码行数:30,代码来源:ModuleInstance.cpp

示例3: end

void
ModuleInstance::order_transitions()
{
	if (!sealed())
#ifndef NDEBUG
		throw_FigException("this module hasn't been sealed yet");
#else
		return;
#endif

	for (const Transition& tr: transitions_) {
		transitions_by_label_[tr.label().str].emplace_back(tr);
		transitions_by_clock_[tr.triggeringClock].emplace_back(tr);
	}

#ifndef NDEBUG
	for (const auto& vec: transitions_by_clock_)
		for (const Transition& tr1: vec.second)
			if (std::find_if(begin(transitions_), end(transitions_),
							 [&tr1](const Transition& tr2) { return &tr1==&tr2; })
				  == end(transitions_))
				throw_FigException("Transition with label \"" + tr1.label().str
								   + "\" and triggering clock \"" + tr1.triggeringClock
								   + "\" isn't mapped in the clocks list !!!");
	for (const auto& vec: transitions_by_label_)
		for (const Transition& tr1: vec.second)
			if (std::find_if(begin(transitions_), end(transitions_),
							 [&tr1](const Transition& tr2) { return &tr1==&tr2; })
				  == end(transitions_))
				throw_FigException("Transition with label \"" + tr1.label().str
								   + "\" and triggering clock \"" + tr1.triggeringClock
								   + "\" isn't mapped in the labels list !!!");
#endif
}
开发者ID:raulmonti,项目名称:FIG,代码行数:34,代码来源:ModuleInstance.cpp

示例4: elapsedTime

const Label&
ModuleInstance::jump(const Traial::Timeout& to,
					 Traial& traial) const
{
#ifndef NDEBUG
	if (!sealed_)
		throw_FigException("this module hasn't been sealed yet");
#endif
	const float elapsedTime(to.value);
	const auto iter = transitions_by_clock_.find(to.name);
	assert(end(transitions_by_clock_) != iter);  // deny foreign clocks
	traial.kill_time(to.gpos, 1ul, 100.0f);      // mark this clock 'expired'
	const auto& transitions = iter->second;
	for (const Transition& tr: transitions) {
		if (tr.pre(traial.state)) { // If the traial satisfies this precondition
			tr.pos(traial.state);   // apply postcondition to its state
			tr.handle_clocks(       // and update clocks according to it.
				traial,
				begin(lClocks_),
				end(lClocks_),
				firstClock_,
				elapsedTime);
            // Finally broadcast the output label triggered
			assert(tr.label().is_output());
			return tr.label();
		}
	}
    // No transition was enabled => advance all clocks and broadcast tau
	traial.kill_time(firstClock_, num_clocks(), elapsedTime);
	return TAU;
}
开发者ID:raulmonti,项目名称:FIG,代码行数:31,代码来源:ModuleInstance.cpp

示例5: main

int main()
{
    // instantiates int compare(const int&, const int&)
    cout << compare(1, 0) << endl;       // T is int

    // instantiates int compare(const vector<int>&, const vector<int>&)
#ifdef LIST_INIT
    vector<int> vec1{1, 2, 3}, vec2{4, 5, 6};
#else
    int temp1[] = {1, 2, 3}, temp2[] = {4, 5, 6};
    vector<int> vec1(begin(temp1), end(temp1)), 
	            vec2(begin(temp2), end(temp2));
#endif
    cout << compare(vec1, vec2) << endl; // T is vector<int>

    long l1, l2;
    int i1, i2;
    compare(i1, i2);      // instantiate compare(int, int)
    compare(l1, l2);      // instantiate compare(long, long)
	compare<int>(i1, l2); // uses compare(int, int)
	compare<long>(i1, l2);// uses compare(long, long)

    const char *cp1 = "hi", *cp2 = "world";
    compare(cp1, cp2);          // calls the specialization
    compare<string>(cp1, cp2);  // converts arguments to string

    return 0;
}
开发者ID:MGZX,项目名称:cpp_primer,代码行数:28,代码来源:compare.cpp

示例6: check

void
check ()
{
  using std::begin;
  using std::end;

  // Initialize the container with a base sequence.
  T seq{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };

  // Construct a random generator over the range.
  auto gen = quantify_over_range (seq);

  // Check that element in the generate range is in the originating vector.
  for (int i = 0; i < 10; ++i)
    {
      auto r = gen ();
      auto first = begin (r);
      auto last = end (r);

      // From the first iterator i where *i == *first, the sequences
      // [first, last) and [i, i + last - first) compare equal.
      if (first != last)
        {
          auto i = find (begin (seq), end (seq), *first);
          assert (equal (first, last, i));
        }
    }
}
开发者ID:hiraditya,项目名称:origin,代码行数:28,代码来源:random.cpp

示例7: main

int main()
{
	int ia[3][4] = {0,0,0,0,0,0,0,0,0,0,0,0};
	// 这里需要注意2维数组,需要使用引用方可使用代范围的for循环
	for(int (&i)[4]:(ia))
	{
		for(int j:i)	
		{
			cout << j << " ";
		}
		cout << endl;
	}
	cout << "---------------"<< endl;
	for(int i = 0; i < 3; i++ )
	{
		int *p = ia[i];	
		for(int j = 0; j < 4; j++)
		{
			cout << p[j] << " ";	
		}
		cout << endl;
	}
	cout << "----------------" << endl;
	for(int (*i)[4] = begin(ia); i != end(ia) ; i++)
	{
		for(int *j = begin(*i); j != end(*i); j++)
		{
			cout << *j << " ";	
		}
		cout << endl;
	}
	cout << "----------------" << endl;
	return 0;
}
开发者ID:MagicSen,项目名称:C_Plus_Plus_Primer,代码行数:34,代码来源:test_3_6_1.cpp

示例8: main

int main()
{
	int ia[3][4] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
	for(int (&row)[4]:ia) // Range for need to use for outfor & instead of *.
	{
		for(int col: row)
		{
			cout << col << "  ";
		}
	}
	cout << endl;

	// Traditional for using index.
	for(int i = 0; i < 3; ++i)
	{
		for(int j = 0; j < 4; ++j)
		{
			cout << ia[i][j] << "  ";
		}
	}
	cout << endl;

	// Traditional for using pointer.
	for(int (* row) [4] = begin(ia); row != end(ia); ++row)
	{
		for(int * col = begin(*row); col != end(*row); ++ col)
		{
			cout << * col << "  ";
		}
	}
	cout << endl;
	return(0);
}
开发者ID:PraflyGod,项目名称:Cpp,代码行数:33,代码来源:Exercise3.43.cpp

示例9: CheckEqualRange

void CheckEqualRange(const Range1& r1, const Range2& r2)
{
    using std::begin;
    using std::end;

    CheckEqualRange(begin(r1), end(r1), begin(r2), end(r2));
}
开发者ID:hansmaad,项目名称:qtl,代码行数:7,代码来源:test_tools.hpp

示例10: test_build_covariance_matrices

void bayesian_kriging_test::test_build_covariance_matrices() {
	Parameter params;
	const point_timeaxis time_axis(ctimes);
	SourceList sources;
	DestinationList destinations;
	build_sources_and_dests(3, 3, 15, 15, 2, 10, time_axis, false, sources, destinations);
	arma::mat K, k;
	utils::build_covariance_matrices(begin(sources), end(sources), begin(destinations), end(destinations), params, K, k);
	TS_ASSERT_EQUALS(K.n_rows, (size_t)9);
	TS_ASSERT_EQUALS(K.n_cols, (size_t)9);
    for (size_t i = 0;i < 3;++i) {
        TS_ASSERT_DELTA(K(i, i), params.sill() - params.nug(), 0.00001);
    }
    // verify symmetry
    for (size_t r = 0;r < 3;++r) {
        for (size_t c = 0;c < 3;++c) {
            TS_ASSERT_DELTA(K(r, c), K(c, r), 1e-9);
        }
    }
    // verify two off diagnoal values
    TS_ASSERT_DELTA(K(0, 1), 2.011082466, 1e-6);
    TS_ASSERT_DELTA(K(0, 2), 0.165079701, 1e-6);
    // verify size of the other matrix
	TS_ASSERT_EQUALS(k.n_rows, (size_t)9);
	TS_ASSERT_EQUALS(k.n_cols, (size_t)15 * 15);
}
开发者ID:statkraft,项目名称:shyft,代码行数:26,代码来源:bayesian_kriging_test.cpp

示例11: stop

void Tunnel::stop()
{
  auto d = Tunnel::_instance->d_func();

  auto stopDispatcherFunc =
    [](TunnelPrivate::DispatcherMap::value_type& pair)
  {
    winfo("Stopping the " + pair.second->name() + " dispatcher...");
    assert(pair.second);
    pair.second->stop();
    winfo("Stopped the " + pair.second->name() + " dispatcher.");
  };
  auto stopReceiverFunc =
    [](TunnelPrivate::ReceiverMap::value_type& pair)
  {
    winfo("Stopping the " + pair.second->name() + " receiver...");
    assert(pair.second);
    pair.second->stop();
    winfo("Stopped the " + pair.second->name() + " receiver.");
  };

  wdebug("Stopping the Tunnel...");
  for_each(begin(d->receivers), end(d->receivers), stopReceiverFunc);
  for_each(begin(d->dispatchers), end(d->dispatchers), stopDispatcherFunc);

  instance()->emitEvent(make_shared<Events::Event>(W_EVENT_TUNNEL_STOP));

  wdebug("Stopped the Tunnel.");
}
开发者ID:jalcine,项目名称:wintermute,代码行数:29,代码来源:tunnel.cpp

示例12: start

void Tunnel::start()
{
  W_SPRV(Tunnel);
  auto startDispatcherFunc =
    [](std::pair<const string, Tunnel::Dispatcher::Ptr> pair)
  {
    winfo("Starting the " + pair.second->name() + " dispatcher...");
    assert(pair.second);
    pair.second->start();
    winfo("Started the " + pair.second->name() + " dispatcher.");
  };
  auto startReceiverFunc =
    [](std::pair<const string, Tunnel::Receiver::Ptr> pair)
  {
    winfo("Starting the " + pair.second->name() + " receiver...");
    assert(pair.second);
    pair.second->start();
    winfo("Started the " + pair.second->name() + " receiver.");
  };

  wdebug("Starting the Tunnel...");
  for_each(begin(d->receivers), end(d->receivers), startReceiverFunc);
  for_each(begin(d->dispatchers), end(d->dispatchers), startDispatcherFunc);

  auto eventPtr = make_shared<Events::Event>(W_EVENT_TUNNEL_START);
  assert(instance()->emitter());
  instance()->emitEvent(eventPtr);

  wdebug("Started the Tunnel.");
}
开发者ID:jalcine,项目名称:wintermute,代码行数:30,代码来源:tunnel.cpp

示例13: main

int main()
{
	int ia[3][4] = {
		{ 0, 1, 2, 3 },
		{ 4, 5, 6, 7 },
		{ 8, 9, 10, 11 }
	};

	/* range for */
	for (auto rows : ia)
		for (auto number : rows)
			cout << number << " ";
	cout << endl;

	/* sub */
	for (auto i = 0; i != 3; ++i)
		for (auto j = 0; j != 4; ++j)
			cout << ia[i][j] << " ";
	cout << endl;

	/* pointer */
	for (auto pRow = begin(ia); pRow != end(ia); ++pRow)
		for (auto pCol = begin(*pRow); pCol != end(*pRow); ++pCol)
			cout << *pCol << " ";
	cout << endl;

	return 0;
}
开发者ID:csyezheng,项目名称:Cpp-Primer,代码行数:28,代码来源:3.45.cpp

示例14: WidgetFlatButton

LanguageButton::LanguageButton(
    std::string const & enable_locales,
    Widget & parent,
    gdi::GraphicApi & drawable,
    FrontAPI & front,
    Font const & font,
    Theme const & theme
)
    : WidgetFlatButton(drawable, *this, this, nullptr, -1,
                       theme.global.fgcolor, theme.global.bgcolor,
                       theme.global.focus_color, 2, font, 7, 7)
    , front(front)
    , parent(parent)
{
    using std::begin;
    using std::end;

    auto LCID = front.get_keylayout();

    {
        auto const keylayouts = Keymap2::keylayouts();
        auto const it = std::find_if(begin(keylayouts), end(keylayouts), [&](Keylayout const * k){
            return k->LCID == LCID;
        });
        if (it == end(keylayouts)) {
            auto & default_layout = Keymap2::default_layout();
            LCID = default_layout.LCID;
            this->locales.push_back({default_layout.locale_name, default_layout.LCID});
        }
        else {
            this->locales.push_back({(*it)->locale_name, (*it)->LCID});
        }
    }


    for (auto && r : get_split(enable_locales, ',')) {
        auto const trimmed_range = trim(r);
        auto cstr = begin(trimmed_range).base();
        auto cend = end(trimmed_range).base();

        auto const keylayouts = Keymap2::keylayouts();
        auto const it = std::find_if(begin(keylayouts), end(keylayouts), [&](Keylayout const * k){
            return strncmp(k->locale_name, cstr, cend-cstr) == 0;
        });
        if (it != end(keylayouts)) {
            if ((*it)->LCID != LCID) {
                this->locales.push_back({(*it)->locale_name, (*it)->LCID});
            }
        }
        else {
            LOG(LOG_WARNING, "Layout \"%.*s\" not found.", static_cast<int>(cend - cstr), cstr);
        }
    }

    this->set_text(this->locales[0].locale_name);

    Dimension dim = this->get_optimal_dim();
    this->set_wh(dim);
}
开发者ID:pykoder,项目名称:redemption,代码行数:59,代码来源:language_button.cpp

示例15: find_first_of

inline Iterator_type<R1> 
find_first_of(R1&& range1, R2&& range2)
{
  using std::begin;
  using std::end;
  return std::find_first_of(begin(range1), end(range1), 
                            begin(range2), end(range2));
}
开发者ID:asutton,项目名称:origin,代码行数:8,代码来源:find.hpp


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