當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。