• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ queue函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: window

window_t* window(
        window_type_t type,
        uint8_t max_size)
{
    debug_print("window()\n");
    
    window_t* new_window = (window_t*) calloc(1, sizeof(window_t));    
    
    new_window->buffer = queue();            
    new_window->type = type;
    new_window->max_size = max_size;
    new_window->autocommit = true;
    
    pthread_mutex_init(&new_window->lock, 0);
    sem_init(&new_window->available, 0, 0);
    
    if (type == WINDOW_TYPE_SNW) {
        new_window->max_size = 1;
    }
    
    success_print("window() succeed\n");
    return new_window;
}
开发者ID:AnwarMohamed,项目名称:librudp,代码行数:23,代码来源:window.c


示例2: queue

/** Find a path with sufficient unused residual capacity.
 *  @return true if a path was found from source to sink.
 */
bool mflo_ffs::findPath() {
	vertex u,v; edge e;
	List queue(g->n());

	while (scale > 0) {
		for (u = 1; u <= g->n(); u++) pEdge[u] = 0;
		queue.addLast(g->src());
		while (!queue.empty()) {
			u = queue.first(); queue.removeFirst();
			for (e = g->firstAt(u); e != 0; e=g->nextAt(u,e)) {
				v = g->mate(u,e);
				if (g->res(u,e) >= scale && pEdge[v] == 0 
				    && v != g->src()) {
					pEdge[v] = e; 
					if (v == g->snk()) return true;
					queue.addLast(v);
				}
			}
		}
		scale /= 2;
	}
	return false;
}
开发者ID:tts-ll,项目名称:grafalgo,代码行数:26,代码来源:mflo_ffs.cpp


示例3: main

// this example demonstrates how to use the mapped_view class to map
// an array of numbers to device memory and use the reduce() algorithm
// to calculate the sum.
int main()
{
    // get default device and setup context
    compute::device gpu = compute::system::default_device();
    compute::context context(gpu);
    compute::command_queue queue(context, gpu);
    std::cout << "device: " << gpu.name() << std::endl;

    // create data on host
    int data[] = { 4, 2, 3, 7, 8, 9, 1, 6 };

    // create mapped view on device
    compute::mapped_view<int> view(data, 8, context);

    // use reduce() to calculate sum on the device
    int sum = 0;
    compute::reduce(view.begin(), view.end(), &sum, queue);

    // print the sum on the host
    std::cout << "sum: " << sum << std::endl;

    return 0;
}
开发者ID:BeauJoh,项目名称:compute,代码行数:26,代码来源:mapped_view.cpp


示例4: GetResourceManager

std::unique_ptr<RenderQueue> BREW::CreateLabelDrawable( std::shared_ptr<const Label> label ) const {
	const auto& font_name = GetProperty<std::string>( "FontName", label );
	const auto& font = GetResourceManager().GetFont( font_name );
	auto font_size = GetProperty<unsigned int>( "FontSize", label );
	auto font_color = GetProperty<sf::Color>( "Color", label );

	std::unique_ptr<RenderQueue> queue( new RenderQueue );

	sf::Text vis_label( label->GetWrappedText(), *font, font_size );
	vis_label.setColor( font_color );

	if( !label->GetLineWrap() ) {
		// Calculate alignment when word wrap is disabled.
		sf::Vector2f avail_space( label->GetAllocation().width - label->GetRequisition().x, label->GetAllocation().height - label->GetRequisition().y );
		sf::Vector2f position( avail_space.x * label->GetAlignment().x, avail_space.y * label->GetAlignment().y );

		vis_label.setPosition( position.x, position.y );
	}

	queue->Add( Renderer::Get().CreateText( vis_label ) );

	return queue;
}
开发者ID:Cruel,项目名称:SFGUI,代码行数:23,代码来源:Label.cpp


示例5: dijkstra

void dijkstra(int source) {
	fill_range(dist, dist + graph.vertex_num, INF); // \SourceRef{source:utility}
	fill_range(prev, prev + graph.vertex_num, -1);
	fill_range<Edge *>(path, path + graph.vertex_num, NULL);
	dist[source] = 0;
	std::set<int, bool(*)(int ,int)> queue(dijkstra_compare); // use binary heap
	for (int vi = 0; vi < graph.vertex_num; ++vi) {
		queue.insert(vi);
	}
	for (; !queue.empty(); ) {
		int u = *queue.begin();
		queue.erase(u);
		for (SPEdge * edge = graph.head[u]; edge != NULL; edge = edge->next) {
			if (queue.count(edge->v) > 0 && dist[edge->u] + edge->w < dist[edge->v]) {
				queue.erase(edge->v);
				dist[edge->v] = dist[edge->u] + edge->w;
				prev[edge->v] = edge->u;
				path[edge->v] = edge;
				queue.insert(edge->v);
			}
		}
	}
}
开发者ID:bromine0x23,项目名称:Algorithm-Reference,代码行数:23,代码来源:sp_dijkstra.cpp


示例6: main

int main(int argc, char *argv[])
{
    perf_parse_args(argc, argv);
    std::cout << "size: " << PERF_N << std::endl;

    compute::device device = compute::system::default_device();
    compute::context context(device);
    compute::command_queue queue(context, device);

    compute::vector<compute::uint_> vector(PERF_N, context);

    compute::default_random_engine rng(queue);
    compute::uniform_int_distribution<compute::uint_> dist(0, 1);

    perf_timer t;
    t.start();
    dist.generate(vector.begin(), vector.end(), rng, queue);
    queue.finish();
    t.stop();
    std::cout << "time: " << t.min_time() / 1e6 << " ms" << std::endl;

    return 0;
}
开发者ID:junmuz,项目名称:compute,代码行数:23,代码来源:perf_uniform_int_distribution.cpp


示例7: YKNewTask

void YKNewTask(void (*task)(void), void*taskStack, unsigned char priority) { /* Creates a new task */
	int ip,sp;

	TCBptr new_task = &YKTCBArray[activeTasks];

	activeTasks++;
	new_task->priority = priority;
	new_task->state = READY;
	new_task->delay = 0;
	new_task->next = NULL;
	new_task->prev = NULL;
	YKRdyList = queue(YKRdyList,new_task);
	ip = (int) task & 0xFFFF;
	sp = (int) taskStack & 0xFFFF;

	sp = initStack(ip,sp);
	new_task->sp = (void*)sp;

	if(runningTask != NULL){
		YKScheduler(0);
	}

}
开发者ID:fminor,项目名称:minormoore,代码行数:23,代码来源:yakc.c


示例8: YKEventSet

void YKEventSet(YKEVENT* e, unsigned mask){
	TCBptr head;
	TCBptr temp;
	int schedule;
	YKEnterMutex();
	e->flags |= mask; /* Set bits from mask to one (leave others unchanged) */
	head = e->tasks;
	e->sFlags = e->flags; /* Save flags that caused this pend */
	/* unblock all tasks associated with this event*/
	schedule = 0;
	while( head != NULL){
		temp = head;
		head = head->next;
		e->tasks = head;
		temp->next = NULL;
		YKRdyList = queue(YKRdyList,temp);
		schedule = 1;
	}
	YKExitMutex();
	if(schedule)
		YKScheduler(0);

}
开发者ID:fminor,项目名称:minormoore,代码行数:23,代码来源:yakc.c


示例9: host

bool KRlprPrinterImpl::setupCommand(TQString& cmd, KPrinter *printer)
{
	// retrieve the KMPrinter object, to get host and queue name
	KMPrinter	*rpr = KMFactory::self()->manager()->findPrinter(printer->printerName());
	if (!rpr)
		return false;

	QString	host(rpr->option("host")), queue(rpr->option("queue"));
	if (!host.isEmpty() && !queue.isEmpty())
	{
		QString		exestr = TDEStandardDirs::findExe("rlpr");
		if (exestr.isEmpty())
		{
			printer->setErrorMessage(i18n("The <b>%1</b> executable could not be found in your path. Check your installation.").arg("rlpr"));
			return false;
		}

		cmd = TQString::fromLatin1("%1 -H %2 -P %3 -\\#%4").arg(exestr).arg(quote(host)).arg(quote(queue)).arg(printer->numCopies());

		// proxy settings
		TDEConfig	*conf = KMFactory::self()->printConfig();
		conf->setGroup("RLPR");
		QString	host = conf->readEntry("ProxyHost",TQString::null), port = conf->readEntry("ProxyPort",TQString::null);
		if (!host.isEmpty())
		{
			cmd.append(" -X ").append(quote(host));
			if (!port.isEmpty()) cmd.append(" --port=").append(port);
		}

		return true;
	}
	else
	{
		printer->setErrorMessage(i18n("The printer is incompletely defined. Try to reinstall it."));
		return false;
	}
}
开发者ID:Fat-Zer,项目名称:tdelibs,代码行数:37,代码来源:krlprprinterimpl.cpp


示例10: main

int main() {
    auto& converter = SKKRomanKanaConverter::theInstance();
    converter.Initialize("kana-rule.conf");

    TestInputQueueObserver observer;
    SKKInputQueue queue(&observer);

    queue.AddChar('a');
    assert(observer.Test("あ", ""));

    observer.Clear();
    queue.AddChar('k');
    assert(observer.Test("", "k"));
    queue.AddChar('y');
    assert(observer.Test("", "ky"));
    queue.RemoveChar();
    assert(observer.Test("", "k"));
    queue.AddChar('i');
    assert(observer.Test("き", ""));

    observer.Clear();
    queue.AddChar('n');
    assert(observer.Test("", "n"));
    queue.Terminate();
    assert(observer.Test("ん", ""));

    queue.AddChar('n');
    assert(queue.CanConvert('i'));

    queue.Terminate();
    observer.Clear();
    queue.AddChar('o');
    queue.AddChar('w');
    queue.AddChar('s');
    queue.AddChar('a');
    assert(observer.Test("おさ", ""));
}
开发者ID:aeg,项目名称:aquaskk,代码行数:37,代码来源:SKKInputQueue_TEST.cpp


示例11: queue

/** Compute exact distance labels and return in distance vector.
 *  For vertices that can't reach sink, compute labels to source.
 */
void mflo_pp::initdist() {
	vertex u,v; edge e;
	List queue(g->n());

	for (u = 1; u < g->n(); u++) d[u] = 2*g->n();

	// compute distance labels for vertices that have path to sink
	d[g->snk()] = 0;
	queue.addLast(g->snk());
	while (!queue.empty()) {
		u = queue.first(); queue.removeFirst();
		for (e = g->firstAt(u); e != 0; e = g->nextAt(u,e)) {
			v = g->mate(u,e);
			if (g->res(v,e) > 0 && d[v] > d[u] + 1) {
				d[v] = d[u] + 1;
				queue.addLast(v);
			}
		}
	}

	if (d[g->src()] < g->n()) 
		Util::fatal("initdist: path present from source to sink");

	// compute distance labels for remaining vertices
	d[g->src()] = g->n();
	queue.addLast(g->src());
	while (!queue.empty()) {
		u = queue.first(); queue.removeFirst();
		for (e = g->firstAt(u); e != 0; e = g->nextAt(u,e)) {
			v = g->mate(u,e);
			if (g->res(v,e) > 0 && d[v] > d[u] + 1) {
				d[v] = d[u] + 1;
				queue.addLast(v);
			}
		}
	}
}
开发者ID:tts-ll,项目名称:grafalgo,代码行数:40,代码来源:mflo_pp.cpp


示例12: intel_wait_engine_idle

void
intel_wait_engine_idle(void)
{
	TRACE(("intel_wait_engine_idle()\n"));

	{
		QueueCommands queue(gInfo->shared_info->primary_ring_buffer);
		queue.PutFlush();
	}

	// TODO: this should only be a temporary solution!
	// a better way to do this would be to acquire the engine's lock and
	// sync to the latest token

	bigtime_t start = system_time();

	ring_buffer &ring = gInfo->shared_info->primary_ring_buffer;
	uint32 head, tail;
	while (true) {
		head = read32(ring.register_base + RING_BUFFER_HEAD)
			& INTEL_RING_BUFFER_HEAD_MASK;
		tail = read32(ring.register_base + RING_BUFFER_TAIL)
			& INTEL_RING_BUFFER_HEAD_MASK;

		if (head == tail)
			break;

		if (system_time() > start + 1000000LL) {
			// the engine seems to be locked up!
			TRACE(("intel_extreme: engine locked up, head %lx!\n", head));
			break;
		}

		spin(10);
	}
}
开发者ID:Karvjorm,项目名称:haiku,代码行数:36,代码来源:engine.cpp


示例13: main

// this example demonstrates how to print the values in a vector
int main()
{
    // get default device and setup context
    compute::device gpu = compute::system::default_device();
    compute::context context(gpu);
    compute::command_queue queue(context, gpu);
    std::cout << "device: " << gpu.name() << std::endl;

    // create vector on the device and fill with the sequence 1..10
    compute::vector<int> vector(10, context);
    compute::iota(vector.begin(), vector.end(), 1, queue);

//[print_vector_example
    std::cout << "vector: [ ";
    boost::compute::copy(
        vector.begin(), vector.end(),
        std::ostream_iterator<int>(std::cout, ", "),
        queue
    );
    std::cout << "]" << std::endl;
//]

    return 0;
}
开发者ID:BeauJoh,项目名称:compute,代码行数:25,代码来源:print_vector.cpp


示例14: main

int main(int argc, char *argv[])
{
    perf_parse_args(argc, argv);
    std::cout << "size: " << PERF_N << std::endl;

    // setup context and queue for the default device
    boost::compute::device device = boost::compute::system::default_device();
    boost::compute::context context(device);
    boost::compute::command_queue queue(context, device);
    std::cout << "device: " << device.name() << std::endl;

    // create vector of random numbers on the host
    std::vector<int> host_vector(PERF_N);
    std::generate(host_vector.begin(), host_vector.end(), rand_int);

    perf_timer t;
    for(size_t trial = 0; trial < PERF_TRIALS; trial++){
        boost::compute::vector<int> device_vector(
            host_vector.begin(), host_vector.end(), queue
        );

        t.start();
        device_vector.erase(
            boost::compute::remove(
                device_vector.begin(), device_vector.end(), 4, queue
            ),
            device_vector.end(),
            queue
        );
        queue.finish();
        t.stop();
    }
    std::cout << "time: " << t.min_time() / 1e6 << " ms" << std::endl;

    return 0;
}
开发者ID:EdKeith,项目名称:compute,代码行数:36,代码来源:perf_erase_remove.cpp


示例15: queue

std::deque<Address> GPU::find(std::vector<FindArgs> &requests) const
{
    cl::CommandQueue queue(context,dev);
//    std::clog<<"Queue and kernel constructed"<<std::endl;
    std::deque<Address> result;
    cl_ulong2 *output=new cl_ulong2[requests.size()];
    cl::Buffer bufOutput(context, CL_MEM_WRITE_ONLY, requests.size()*sizeof(cl_ulong2));
//    std::clog<<"Output buffer ready"<<std::endl;
    cl::Buffer bufArgs(context, requests.data(), requests.data()+requests.size(), true, true);
//    std::clog<<"Args buffer ready"<<std::endl;
    cl::make_kernel<cl::Buffer&,cl::Buffer&,cl::Buffer&> find(kfind);
    find(cl::EnqueueArgs(queue, cl::NDRange(requests.size())), *bufData, bufArgs, bufOutput);
    queue.finish();
//    std::clog<<"Kernels executed"<<std::endl;
    cl::copy(queue, bufOutput, output, output+requests.size());
    queue.finish();
    for(size_t i=0;i<requests.size();++i)
    {
        if(output[i].s[0]!=-1)
            result.push_back(Address(output[i].s[0],output[i].s[1]));
    }
    delete []output;
    return result;
}
开发者ID:jpotoniec,项目名称:MagicStore,代码行数:24,代码来源:GPU.cpp


示例16: find_dijkstra

bool find_dijkstra() {
	fill_range(cost, cost + graph.vertex_num, INF); // \SourceRef{source:utility}
	fill_range(prev, prev + graph.vertex_num, -1);
	fill_range<Edge *>(path, path + graph.vertex_num, NULL);
	cost[source] = 0;
	std::set<int, bool(*)(int ,int)> queue(dijkstra_compare);
	for (int vi = 0; vi < graph.vertex_num; ++vi) {
		queue.insert(vi);
	}
	for (; !queue.empty(); ) {
		int u = *queue.begin();
		queue.erase(u);
		for (Edge * edge = graph.head[u]; edge != NULL; edge = edge->next) {
			if (queue.count(edge->v) > 0 && edge->flow < edge->capacity && cost[edge->u] + edge->cost < cost[edge->v]) {
				queue.erase(edge->v);
				cost[edge->v] = cost[edge->u] + edge->cost;
				prev[edge->v] = edge->u;
				path[edge->v] = edge;
				queue.insert(edge->v);
			}
		}
	}
	return cost[sink] != INF;
}
开发者ID:bromine0x23,项目名称:Algorithm-Reference,代码行数:24,代码来源:mcf_dijkstra.cpp


示例17: ser_queue

queue
ser_queue( )
{
  auto comm = std::make_shared< ser_queue_comm >( );

  queue q( queue_type::serial, [comm = std::move( comm )]( queue & q ) {
    boost::lock_guard< boost::mutex > lock( comm->mt_qu );

    comm->qu.append_queue( { steal_work, q } );

    if ( comm->cor_sched ) {
      return;
    }

    queue q_ser( queue_type::serial );

    q_ser.submit_work( [comm]( ) mutable {
      boost::lock_guard< event::mutex > lock_exec( comm->mt_exec );
      boost::unique_lock< boost::mutex > lock( comm->mt_qu );

      assert( comm->cor_sched );

      comm->cor_sched = false;
      auto q_work     = std::move( comm->qu );
      comm->qu        = queue( queue_type::serial );
      lock.unlock( );

      q_work.run_until_empty( );
    } );

    schedule_queue( std::move( q_ser ) );
    comm->cor_sched = true;
  } );

  return q;
}
开发者ID:nikux,项目名称:game_engine,代码行数:36,代码来源:util_queue.cpp


示例18: queue

//--------------------------------------------------------------------------------------------------
bool Index::reachable_bfs(unsigned x, unsigned y) {
  if (x == y)
    return true;
  ++queryId;
  std::deque<unsigned> queue(1, x);
  unsigned v;
  const std::vector<unsigned> *nb;
  while (!queue.empty()) {
    v = queue.front();
    queue.pop_front();
    if (visited[v] == queryId)
      continue;
    visited[v] = queryId;
    ++expanded;
    nb = g->get_neighbors(v);
    for (std::vector<unsigned>::const_iterator it = nb->begin();
        it != nb->end(); ++it) {
      if (y == *it)
        return true;
      queue.push_back(*it);
    }
  }
  return false;
}
开发者ID:agubichev,项目名称:rdf3x_path,代码行数:25,代码来源:Index.cpp


示例19: main

int main( void )
{
   videoQueue_t queue( 320, 240 );
   printf( "entry size %u\n", queue.entrySize_ );
   printf( "row stride %u\n", queue.rowStride_ );

   unsigned idx = NUMENTRIES ;
   videoQueue_t::entry_t *entry ;

   while( 0 != ( entry = queue.getEmpty() ) )
   {
      printf( "empty %u, %p\n", idx, entry );
      entry->when_ms_ = idx-- ;
      queue.putFull( entry );
   }

   while( 0 != ( entry = queue.getFull() ) )
   {
      printf( "full " I64FMT ", %p\n", entry->when_ms_, entry );
      queue.putEmpty( entry );
   }
   
   return 0 ;
}
开发者ID:boundarydevices,项目名称:bdScript,代码行数:24,代码来源:videoQueue.cpp


示例20: queue

void LLEventQueue::flush()
{
	if(!mSignal) return;
		
    // Consider the case when a given listener on this LLEventQueue posts yet
    // another event on the same queue. If we loop over mEventQueue directly,
    // we'll end up processing all those events during the same flush() call
    // -- rather like an EventStream. Instead, copy mEventQueue and clear it,
    // so that any new events posted to this LLEventQueue during flush() will
    // be processed in the *next* flush() call.
    EventQueue queue(mEventQueue);
    mEventQueue.clear();
    // NOTE NOTE NOTE: Any new access to member data beyond this point should
    // cause us to move our LLStandardSignal object to a pimpl class along
    // with said member data. Then the local shared_ptr will preserve both.

    // DEV-43463: capture a local copy of mSignal. See LLEventStream::post()
    // for detailed comments.
    boost::shared_ptr<LLStandardSignal> signal(mSignal);
    for ( ; ! queue.empty(); queue.pop_front())
    {
        (*signal)(queue.front());
    }
}
开发者ID:NanaYngvarrdottir,项目名称:Virtual-Reality-Viewer-3,代码行数:24,代码来源:llevents.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ queue_add函数代码示例发布时间:2022-05-30
下一篇:
C++ query_yn函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap