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


C++ Enqueue函数代码示例

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


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

示例1: AudioSource

	void Player::Enqueue (const QStringList& paths, bool sort)
	{
		QList<AudioSource> parsedSources;
		for (const auto& path : paths)
			parsedSources << AudioSource (path);
		Enqueue (parsedSources, sort);
	}
开发者ID:SboichakovDmitriy,项目名称:leechcraft,代码行数:7,代码来源:player.cpp

示例2: BasicStatementTask

ACE_Future<QueryResult_AutoPtr> DatabaseWorkerPool::AsyncQuery(const char* sql)
{
    QueryResultFuture res;
    BasicStatementTask* task = new BasicStatementTask(sql, res);
    Enqueue(task);
    return res;         //! Fool compiler, has no use yet
}
开发者ID:Meandro,项目名称:wowcore,代码行数:7,代码来源:DatabaseWorkerPool.cpp

示例3: refer_page

int refer_page (int pagenumber, int hash[], Queue *q)
{

	listnode *node = hash[pagenumber];

	if (node) {
		/* Page was found in the hash. Move the page to the top */

		if (q->head == node) {
			/* already in front nothing to do */
		} else if (q->tail == node) {
			/* remove this node from tail and put it in the front */
			tail = tail->left;
			node->right = q->head;
			q->head->left = node;
			q->head = node;
		} else {
			node->left->right = node->right;
			node->right->left = node->left;

			node->right = q->head;
			q->head->left = node;
			q->head = node;
		}
	} else {
		node = newlistnode(pagenumber);
		Enqueue (node, q);
		hash[pagenumber] = node;
	}
	return 0;
}
开发者ID:deepw,项目名称:FirstRepo,代码行数:31,代码来源:lru.c

示例4: EnqueueString

void EnqueueString(char* X, Queue* Q)
{
	/*enqueue elements one by one*/
	int i;
	for(i=0; X[i]; i++)
		Enqueue((unsigned char)X[i], Q);
}
开发者ID:dev-zzo,项目名称:Embsys,代码行数:7,代码来源:embsys_uart_queue.c

示例5: main

main(int argc, char **argv) {  
  if (argc < 2) return 0;
  int port;
  if (sscanf(argv[1], "%d", &port) != 1) return 0;
  sockaddr_in serv;
  int sd = NewSock();
  if (sd < 0 || Bind(sd, port) < 0) return -1;
  while(1) {
    if (!Ready(sd, -1)) continue;
    char mes[516];
    sockaddr_in client;
    socklen_t c_len = sizeof(client);
    int l = recvfrom(sd, mes, 516, 0, (struct sockaddr *)&client, &c_len), stat;
    pid_t sub;
    while (qn > 0 && (sub = waitpid(-1, &stat, WNOHANG))) Dequeue(sub);
    if (Inqueue(client)) {
      fprintf(stderr, "get op = %d\n", *(short *)mes);
      continue;
    }
    sub = fork();
    if (!sub) {
      Serve(mes, client);
      _exit(0);
    }
    Enqueue(client, sub);
  }
}
开发者ID:dk00,项目名称:old-stuff,代码行数:27,代码来源:serv.c

示例6: insert

// Function to insert a new node in complete binary tree
void insert(struct node **root, int data, struct Queue* queue)
{
    // Create a new node for given data
    struct node *temp = newNode(data);

    // If the tree is empty, initialize the root with new node.
    if (!*root)
        *root = temp;

    else
    {
        // get the front node of the queue.
        struct node* front = getFront(queue);

        // If the left child of this front node doesn’t exist, set the
        // left child as the new node
        if (!front->left)
            front->left = temp;

        // If the right child of this front node doesn’t exist, set the
        // right child as the new node
        else if (!front->right)
            front->right = temp;

        // If the front node has both the left child and right child,
        // Dequeue() it.
        if (hasBothChild(front))
            Dequeue(queue);
    }

    // Enqueue() the new node for later insertions
    Enqueue(temp, queue);
}
开发者ID:bits3dec,项目名称:DS-and-Algorithms,代码行数:34,代码来源:Binarytree_search+_recursion.c

示例7: UnblockWaiters

  static void UnblockWaiters(BuildQueue* queue, NodeState* node)
  {
    const NodeData *src_node       = node->m_MmapData;
    int             enqueue_count  = 0;

    for (int32_t link : src_node->m_BackLinks)
    {
      if (NodeState* waiter = GetStateForNode(queue, link))
      {
        // Only wake nodes in our current pass
        if (waiter->m_MmapData->m_PassIndex != queue->m_CurrentPassIndex)
          continue;

        // If the node isn't ready, skip it.
        if (!AllDependenciesReady(queue, waiter))
          continue;

        // Did someone else get to the node first?
        if (NodeStateIsQueued(waiter) || NodeStateIsActive(waiter))
          continue;

        //printf("%s is ready to go\n", GetSourceNode(queue, waiter)->m_Annotation);
        Enqueue(queue, waiter);
        ++enqueue_count;
      }
    }

    if (enqueue_count > 0)
      WakeWaiters(queue, enqueue_count);
  }
开发者ID:MadFishTheOne,项目名称:tundra,代码行数:30,代码来源:BuildQueue.cpp

示例8: main

/* 
 * ===  FUNCTION  ======================================================================
 *         Name:  main
 *  Description:  
 * =====================================================================================
 */
    int
main ( int argc, char *argv[] )
{
    int k=0;
    Queue my_queue;
    Tree_node my_tree_node;
    Queue_node dequeue_node;

    my_tree_node	= malloc ( sizeof(struct tree_node) );
    if ( my_tree_node==NULL ) {
        fprintf ( stderr, "\ndynamic memory allocation failed\n" );
        exit (EXIT_FAILURE);
    }
    my_tree_node->data='A';
    my_tree_node->firstchild=NULL;
    my_tree_node->nextsibling = NULL;

    my_queue = Init_Queue();
    for(k=0;k<7;k++)
    {
        Enqueue(my_queue, my_tree_node);
        my_tree_node->data='A'+k+1;
    }
    Print_Queue(my_queue);
    printf("\n");
    while((dequeue_node=Dequeue(my_queue))!=NULL)
    {
        printf("<!!%c!!>\n",dequeue_node->node_data.data);
        free(dequeue_node);
        Print_Queue(my_queue);
        printf("**************************\n\n");
    }
    return EXIT_SUCCESS;
}				/* ----------  end of function main  ---------- */
开发者ID:qeesung,项目名称:data-struct,代码行数:40,代码来源:test_queue.c

示例9: process

/**
 * Main loop for processing segments
 * @param ptr		useless
 */
static void * process(void * ptr) {
	Bucket * b = NULL;
	Segment * seg = NULL;
	int turn = 0;
	while ((seg = (Segment *) Dequeue(service._iq)) != NULL) {
		if (seg->unique) {
			b = BucketInsert(b, seg);
		}
		Enqueue(service._oq, seg);
	}
	if (b != NULL) {
		SaveBucket(b);
	}
	Enqueue(service._oq, NULL);
	return NULL;
}
开发者ID:111220187,项目名称:revdedup,代码行数:20,代码来源:bucket.c

示例10: BasicPQueueTest

void BasicPQueueTest(void)
{
	int i;
	pqueueADT pq;

	printf("\n-----------   Testing Basic PQueue functions -----------\n\n");
	pq = NewPQueue();
	printf("The pqueue was just created.  Is it empty? %s", IsEmpty(pq) ? "TRUE" : "FALSE");

	for (i = 1; i <= 10; i++)
		Enqueue(pq, i);

	printf("\nEnqueuing the integers from 1 to 10 (in forward order)\n");
	printf("Pqueue should not be empty. Is it empty? %s\n", IsEmpty(pq) ? "TRUE" : "FALSE");
	printf("Dequeuing the top 5 elements: ");

	for (i = 0; i < 5; i++)
		printf("%d ", DequeueMax(pq));

	printf("\nDequeuing all the rest: ");
	while (!IsEmpty(pq))
		printf("%d ", DequeueMax(pq));

	printf("\nPqueue should be empty.  Is it empty? %s\n", IsEmpty(pq) ? "TRUE" : "FALSE");

	FreePQueue(pq);
	printf("Hit return to continue: ");
	{
		string s = GetLine();
		FreeBlock(s);
	}
}
开发者ID:Tkocz,项目名称:DOPlab2,代码行数:32,代码来源:pqueuetest.c

示例11: main

int main(){	
	// create queue
	int queue[QUEUE_SIZE]={0};
	int rear = 0;
	int front = 0;
	int choice;
	while(1){
		showInitile();
		choice = getChoice();
		switch(choice){
			case 1:
				displayQueue(queue);
				break;
			case 2:
				Enqueue(queue, &rear, &front);
				break;
			case 3:
				delqueue(queue, &rear, &front);
				break;
			case 4:
				system("CLS");
				break;
			default:
				printf("你壞壞\n");
				break;
		}
	}
	system("pause");
	return 0;
}
开发者ID:Heng-xiu,项目名称:DataStructure,代码行数:30,代码来源:queue_array.cpp

示例12: shortestpath

//BFS algorithm
int shortestpath(Node *array, int Vnum, int root, int des)
{
    int i,out,ss;
    //create a queue
    Queue *head=Initqueue();
    Queue *path=Initqueue();
    Node *travel,*p;
    int *color = (int *)malloc(Vnum*sizeof(int));
    int *father = (int *)malloc(Vnum*sizeof(int));
    for(i=0;i<Vnum;i++)father[i]=i;
    for(i=0;i<Vnum;i++)color[i]=white;  //initialize colar
    Enqueue(head,root);
    color[root]=grey;
    father[root]=root;
    while(Isempty(head)!=1)
    {
        out = Dequeue(head);
        travel=array+out;
        for(p=travel->next;p!=NULL;p=p->next)
        {
            if(color[p->ID]==white)
            {
                Enqueue(head,p->ID);
                color[p->ID]=grey;
                father[p->ID]=out;
            }
        }
        color[out]=black;
    }
    if(color[des]==white)
    {
        printf("Error: there is no path between %d and %d.",root,des);
        ss=false;
    }
    else
    {
        //if there is a path, then print it out
        //for(i=0;i<Vnum;i++)printf("%d is father of %d\n",father[i],i);
        PrintPath(father,root,des);
        ss=true;     
    }
    Clearqueue(head);
    Destroyqueue(head);
    free(color);
    free(father);
    return ss;
}
开发者ID:EuphieLiu,项目名称:Assignment1,代码行数:48,代码来源:a4-ece650.c

示例13: main

int main()
{
 Queue Q;
 Q = CreateQueue(4);

 Enqueue(1,Q);
 Enqueue(2,Q);
 Enqueue(3,Q);
 Enqueue(4,Q);
 
 printf("Size  of queue is : %d and rear is :%d\n",Q->size,Q->rear);
  
 Dequeue(Q);
 printf("Size  of queue is : %d and front is : %d\n",Q->size,Q->front);
  
 return 0;
}
开发者ID:Gurpreet1928,项目名称:Programming_Codes,代码行数:17,代码来源:queue.c

示例14: sizeof

/**
* In CPU-Transfer-Mode the API will add the length descriptor for us. In DMA mode we also use this behavior (it is,
* however, redundant to the HPRPC protocol ... maybe it'd be the best to change the protocol ...)
*
* In DMA mode we prefix the transfer with the transfer length (and set the MSB to signalize DMA mode)
* Here we add only a placeholder, later we will overwrite it during Send() (see OverwriteStartToken()).
*/
void CBufferedWriter::EnqueueDummyStartToken()
{

	uint32_t lengthPlaceholder = 0;
	uint32_t sizeofPlaceholder = sizeof(lengthPlaceholder);
	Enqueue((uint8_t*)(&lengthPlaceholder), sizeofPlaceholder);
	m_pLengthPrefix = (uint32_t*)(m_KernelBufCursor - sizeofPlaceholder);	//remember this place, we will write the total length to it when we finally send the buffers
}
开发者ID:RoelofBerg,项目名称:fimreg,代码行数:15,代码来源:CBufferedWriter.cpp

示例15: Serial_Enter

void Serial_Enter( serial_t serial)
{
	pthread_t tid = pthread_self();
	Enqueue(serial->queues[0],tid,NULL);
	while( pthread_equal(serial->queues[0]->head->id,tid)==0);
	pthread_mutex_lock(&(serial->mutexlock));
	Dequeue(serial->queues[0]);
}  
开发者ID:diegowangyz,项目名称:psu_serializer,代码行数:8,代码来源:serial.c


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