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


C++ deque::emplace_back方法代码示例

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


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

示例1: reserve_read

  /** Reserve some part of the pipe for reading

      \param[in] s is the number of element to reserve

      \param[out] rid is an iterator to a description of the
      reservation that has been done if successful

      \param[in] blocking specify if the call wait for the operation
      to succeed

      \return true if the reservation was successful
  */
  bool reserve_read(std::size_t s,
                    rid_iterator &rid,
                    bool blocking = false)  {
    // Lock the pipe to avoid being disturbed
    std::unique_lock<std::mutex> ul { cb_mutex };

    TRISYCL_DUMP_T("Before read reservation cb.size() = " << cb.size()
                   << " size() = " << size());
    if (s == 0)
      // Empty reservation requested, so nothing to do
      return false;

    if (blocking)
      /* If in blocking mode, wait for enough elements to read in the
         pipe for the reservation. This condition can change when a
         write is done */
      write_done.wait(ul, [&] { return s <= size(); });
    else if (s > size())
      // Not enough elements to read in the pipe for the reservation
      return false;

    // Compute the location of the first element of the reservation
    auto first = cb.begin() + read_reserved_frozen;
    // Increment the number of frozen elements
    read_reserved_frozen += s;
    /* Add a description of the reservation at the end of the
       reservation queue */
    r_rid_q.emplace_back(first, s);
    // Return the iterator to the last reservation descriptor
    rid = r_rid_q.end() - 1;
    TRISYCL_DUMP_T("After reservation cb.size() = " << cb.size()
                   << " size() = " << size());
    return true;
  }
开发者ID:loic-yvonnet,项目名称:triSYCL,代码行数:46,代码来源:pipe.hpp

示例2: Enter

void Enter(Activity *activity) {
	if (current) {
		stack.emplace_back(current);
	}
	current = activity;
	current->dispatchStart();
}
开发者ID:ds84182,项目名称:Files,代码行数:7,代码来源:manager.cpp

示例3:

 S4() {
    for(int i = 0; i < 6; ++i) {
       m_s1.emplace_back();
       m_s2.emplace_back();
       m_s3.emplace_back();
    }
 }
开发者ID:alexeevm,项目名称:voltdb,代码行数:7,代码来源:pool_test.cpp

示例4: disambiguate

static inline void propagate_age_update(Cfg& conf, std::deque<Cfg>& tmpres, std::size_t dst) {
	// here we propagate an age field update to all pointers that are equal
	// and thus experience the update too => only for age updates of next fields

	// split to find truly equal pointers
	auto shape_split = disambiguate(*conf.shape, dst);

	for (Shape* s : shape_split) {
		tmpres.emplace_back(Cfg(conf, s));
		Cfg& config = tmpres.back();

		// pointer equal to dst => experiences age update too
		for (std::size_t i = 0; i < s->size(); i++) {
			if (i == dst) continue;
			if (s->test(i, dst, EQ)) {
				#if CAS_OVERAPPROXIMATE_AGE_PROPAGATION
					// overapproximation: drop age relation of pointers that observe the age assignemnt
					for (std::size_t j = 0; j < s->size(); j++)
						for (bool b : {false, true})
							config.ages->set(j, b, i, true, AgeRel::BOT);
				#else
					mk_next_age_equal(config, i, dst, true);
				#endif
			}
		}
	}

	// the shape/ages from conf may no longer be valid => overwrite the shape/ages
	conf.shape = std::move(tmpres.back().shape);
	conf.ages = std::move(tmpres.back().ages);
	tmpres.pop_back();
}
开发者ID:Wolff09,项目名称:TMRexp,代码行数:32,代码来源:eval_cas.cpp

示例5: Next

int Cursor::Next(const size_t count, std::deque<nx::String>& buf)
{
	int rs = 0;
	if (isShared())
	{
		if (extra_state_ && extra_state_->IsReady())
		{  // +extra with mixing
			std::string rs = extra_state_->Get(extra_delim_);
			buf.emplace_back(rs.begin(), rs.end());
			++(*extra_state_);
			rs = 1;
		}
		else
		{
				std::deque<nx::String> tmpbuf;
				rs = do_next(count * shared_total_, tmpbuf);
				if(rs >= 0)
					for(size_t i = 0, j = shared_curr_ - 1; i < count && j < tmpbuf.size();
							++i, j = shared_curr_ - 1 + shared_total_*i )
					{
						buf.push_back(tmpbuf[j]);
					}
		}
	}
	else
	{
		++(*extra_state_);
		rs = do_next(count, buf);
	}
	return rs;
}
开发者ID:hoxnox,项目名称:cursord,代码行数:31,代码来源:cursor.cpp

示例6: createPlugins

void createPlugins(MyPluginFactory& factory, const std::vector<std::string>& availablePlugins, std::deque<MyPlugin>& plugins)
{
    for(const auto& pluginName : availablePlugins)
    {
        plugins.emplace_back(factory.instance(pluginName));
    }
}
开发者ID:paxos1977,项目名称:PluginFactory,代码行数:7,代码来源:main.cpp

示例7: run_on_main_thread

void run_on_main_thread(std::function<void()> &func) {

    {
       std::unique_lock<std::mutex> lock(main_thread_mutex);
       main_func.emplace_back(func);
    }
    main_thread_cv.notify_all();
    std::unique_lock<std::mutex> lock(main_thread_mutex);
    main_thread_cv.wait(lock, []{ return main_done || main_func.empty(); });
}
开发者ID:vistle,项目名称:vistle,代码行数:10,代码来源:vistle_manager.cpp

示例8: Enqueue

 /** Enqueue a work item */
 bool Enqueue(WorkItem* item)
 {
     boost::unique_lock<boost::mutex> lock(cs);
     if (queue.size() >= maxDepth) {
         return false;
     }
     queue.emplace_back(std::unique_ptr<WorkItem>(item));
     cond.notify_one();
     return true;
 }
开发者ID:dankcoin,项目名称:dankcoin,代码行数:11,代码来源:httpserver.cpp

示例9: element_is_ready

	void element_is_ready() {
		std::unique_lock<std::mutex> guard(m_lock);
		m_elements.emplace_back(std::move(m_current));
		m_current.reset(new element);

		if (m_elements.size() > m_pool.size() * 2) {
			m_parser_wait.wait(guard, [&] {return m_elements.size() < m_pool.size();});
		}

		guard.unlock();
		m_pool_wait.notify_one();
	}
开发者ID:reverbrain,项目名称:ribosome,代码行数:12,代码来源:xml.hpp

示例10: addAndSetTime

    // ------------------------------------------------------------------------
    void addAndSetTime(uint32_t ping, uint64_t server_time)
    {
        if (m_synchronised.load() == true)
            return;

        if (m_force_set_timer.load() == true)
        {
            m_force_set_timer.store(false);
            m_synchronised.store(true);
            STKHost::get()->setNetworkTimer(server_time + (uint64_t)(ping / 2));
            return;
        }

        const uint64_t cur_time = StkTime::getMonoTimeMs();
        // Discard too close time compared to last ping
        // (due to resend when packet loss)
        // 10 packets per second as seen in STKHost
        const uint64_t frequency = (uint64_t)((1.0f / 10.0f) * 1000.0f) / 2;
        if (!m_times.empty() &&
            cur_time - std::get<2>(m_times.back()) < frequency)
            return;

        // Take max 20 averaged samples from m_times, the next addAndGetTime
        // is used to determine that server_time if it's correct, if not
        // clear half in m_times until it's correct
        if (m_times.size() >= 20)
        {
            uint64_t sum = std::accumulate(m_times.begin(), m_times.end(),
                (uint64_t)0, [cur_time](const uint64_t previous,
                const std::tuple<uint32_t, uint64_t, uint64_t>& b)->uint64_t
                {
                    return previous + (uint64_t)(std::get<0>(b) / 2) +
                        std::get<1>(b) + cur_time - std::get<2>(b);
                });
            const int64_t averaged_time = sum / 20;
            const int64_t server_time_now = server_time + (uint64_t)(ping / 2);
            int difference = (int)std::abs(averaged_time - server_time_now);
            if (std::abs(averaged_time - server_time_now) <
                UserConfigParams::m_timer_sync_difference_tolerance)
            {
                STKHost::get()->setNetworkTimer(averaged_time);
                m_times.clear();
                m_force_set_timer.store(false);
                m_synchronised.store(true);
                Log::info("NetworkTimerSynchronizer", "Network "
                    "timer synchronized, difference: %dms", difference);
                return;
            }
            m_times.erase(m_times.begin(), m_times.begin() + 10);
        }
        m_times.emplace_back(ping, server_time, cur_time);
    }
开发者ID:supertuxkart,项目名称:stk-code,代码行数:53,代码来源:network_timer_synchronizer.hpp

示例11: append

    void
    append(Args&&... args) {
        static_assert(
            std::is_same<typename Event::tag, Tag>::value,
            "message protocol is not compatible with this message queue"
        );

        if(!upstream_) {
            return operations.emplace_back(aux::make_frozen<Event>(std::forward<Args>(args)...));
        }

        upstream_->send<Event>(std::forward<Args>(args)...);
    }
开发者ID:bdacode,项目名称:cocaine-core,代码行数:13,代码来源:queue.hpp

示例12: DbgTimingInfo

void ProfileDrawer::DbgTimingInfo(DbgTimingInfoType type, const spring_time start, const spring_time end)
{
	if (!IsEnabled())
		return;

	switch (type) {
		case TIMING_VIDEO: {
			vidFrames.emplace_back(start, end);
		} break;
		case TIMING_SIM: {
			simFrames.emplace_back(start, end);
		} break;
		case TIMING_GC: {
			lgcFrames.emplace_back(start, end);
		} break;
		case TIMING_SWAP: {
			swpFrames.emplace_back(start, end);
		} break;
		case TIMING_UNSYNCED: {
			uusFrames.emplace_back(start, end);
		} break;
	}
}
开发者ID:9heart,项目名称:spring,代码行数:23,代码来源:ProfileDrawer.cpp

示例13: dispatcher_

 result_type
 traverse(std::conditional_t< reassmble, ast::expression &&, ast::expression const & > _input)
 { // if reassmble is true, then input is taken apart, then reassembled
     assert(output_.empty());
     if (_input.rest_.empty()) {
         return dispatcher_(std::move(_input.first_));
     } else if (_input.rest_.size() == 1) {
         auto & operation_ = _input.rest_.back();
         return dispatcher_(std::move(_input.first_),
                            operation_.operator_,
                            std::move(operation_.operand_));
     } else {
         //output_.reserve(_input.rest_.size() * 2 + 1); // total number of operators and operands
         std::stack< aggregate_wrapper< lhs_op > > lhs_op_;
         for (auto & operation_ : _input.rest_) {
             size_type const precedence_ = ast::precedence(operation_.operator_);
             while (!lhs_op_.empty()) {
                 lhs_op const & top_ = lhs_op_.top();
                 if (ast::precedence(top_.operator_) < precedence_) {
                     break;
                 }
                 output_.emplace_back(top_.lhs_, top_.operator_, output_.size());
                 lhs_op_.pop();
             }
             lhs_op_.emplace(output_.size(), operation_.operator_);
             output_.emplace_back(&operation_.operand_);
         }
         while (!lhs_op_.empty()) {
             lhs_op const & top_ = lhs_op_.top();
             output_.emplace_back(top_.lhs_, top_.operator_, output_.size());
             lhs_op_.pop();
         }
         output_.emplace_front(&_input.first_);
         return operator () (output_.back());
     }
 }
开发者ID:tomilov,项目名称:insituc,代码行数:36,代码来源:shunting_yard_algorithm.hpp

示例14: getCachedFile

	std::unique_ptr<ui8[]> getCachedFile(ResourceID rid)
	{
		for(auto & file : cache)
		{
			if (file.name == rid)
				return file.getCopy();
		}
		// Still here? Cache miss
		if (cache.size() > cacheSize)
			cache.pop_front();

		auto data =  CResourceHandler::get()->load(rid)->readAll();

		cache.emplace_back(std::move(rid), data.second, std::move(data.first));

		return cache.back().getCopy();
	}
开发者ID:argarak,项目名称:vcmi,代码行数:17,代码来源:CAnimation.cpp

示例15: addComponent

	ComponentType& addComponent(Args&&... args)
	{
		static_assert(std::is_base_of<NodeComponent, ComponentType>::value,
		              "ComponentType must inherit from NodeComponent.");
		assert(!hasComponent<ComponentType>() &&
		       "SceneNode::addComponent component of that type already exists.");

		ComponentType* component{
		    new ComponentType{std::forward<Args>(args)...}};
		component->parent = this;
		components.emplace_back(std::unique_ptr<NodeComponent>{component});

		componentArray[getComponentTypeId<ComponentType>()] = component;
		componentBitset[getComponentTypeId<ComponentType>()] = true;

		return *component;
	}
开发者ID:Kitsune001,项目名称:Dunjun,代码行数:17,代码来源:SceneNode.hpp


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