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

C++ queue_is_empty函数代码示例

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

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



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

示例1: queue_tail_del

void
queue_tail_del(struct queue * q)
{
    if (!queue_is_empty(q)) {
        queue_item_del(q->elems[q->tail]);
        free(q->elems[q->tail]);
        q->elems[q->tail] = NULL;
        q->tail = (q->tail + 1) % q->max_size;
        pthread_mutex_lock(&q->mux);
        {
            q->nr_elems--;
            if (queue_is_empty(q))
                pthread_cond_wait(&q->not_empty, &q->mux);
            pthread_cond_signal(&q->not_full);
        }
        pthread_mutex_unlock(&q->mux);
    }
}
开发者ID:aicastell,项目名称:wheebop,代码行数:18,代码来源:queue.c


示例2: START_TEST

} END_TEST


/* ************************************************************ */
/* bug tests                                                    */
/* ************************************************************ */
START_TEST(test_bug005562) {
	/*
	 * BUG 005562: Segfault after sending REGISTER to an invalid address (no registrar aat this address) and waiting >30sec
	 */

	sipstack_event *event;

	sipstack_init();

	int counter = 0;

	/* send REGISTER */
	int regId =
		sipstack_send_register("sip:"TEST_SIPSTACK_USER"@192.168.0.1", "sip:192.168.0.99", 1800);
	fail_unless(regId > -1, "Sending REGISTER failed. (result = %i)", regId);

	/* receive response */
	while (queue_is_empty(event_queue) && counter < 60) {
		sleep(1);
		counter++;
	}

	fail_unless(!queue_is_empty(event_queue), TEST_SIPSTACK_PREFIX "No response for registering received.");

	event = queue_front_and_dequeue(event_queue);

	/* expect REGISTRATION_FAILURE (2) */
	/* test failed*/
	if(event->type != 2) {
		/* free allocated memory before test fails */
		sipstack_event_free(event);
	}
	fail_unless(event->type == 2,
				"No event of type REGISTRATION_FAILURE received. (type = %i)", event->type);

	sipstack_event_free(event);
	sipstack_quit();
} END_TEST
开发者ID:BackupTheBerlios,项目名称:partisipation-svn,代码行数:44,代码来源:test_sipstack.c


示例3: floodfill

void
floodfill(unsigned long * pixels, int x, int y, int width, int height,unsigned long color) {

    printf("\nEntrando to floodfill\n");
    queue *lista_xy;
    
    lista_xy = queue_init();

    int color_start = pixels[x + y * width];
   
    if (color != color_start) {
        queue_enqueue(x, lista_xy);
        queue_enqueue(y, lista_xy);

        pixels[x + y * width] = color;

        while (!queue_is_empty(lista_xy)) {
            if (x + 1 < width) {
                if (pixels[(x + 1) + y * width] == color_start) {
                    pixels[(x + 1) + y * width] = color;
                    queue_enqueue(x+1, lista_xy);
                    queue_enqueue(y, lista_xy);
                }
            }

            if (x - 1 >= 0){
                if (pixels[(x - 1) + y * width] == color_start) {
                    pixels[(x - 1) + y * width] = color;
                    queue_enqueue(x-1, lista_xy);
                    queue_enqueue(y, lista_xy);
                }
            }

            if (y + 1 < height){
                if (pixels[x + (y + 1) * width] == color_start) {
                    pixels[x + (y + 1) * width] = color;
                    queue_enqueue(x, lista_xy);
                    queue_enqueue(y+1, lista_xy);
                }
            }

            if (y - 1 >= 0){
                if (pixels[x + (y - 1) * width] == color_start){
                    pixels[x + (y - 1) * width] = color;
                    queue_enqueue(x, lista_xy);
                    queue_enqueue(y-1, lista_xy);
                }
            }
            x = lista_xy->front->info;
            queue_dequeue(lista_xy);
            y = lista_xy->front->info;
            queue_dequeue(lista_xy);
       }
   }
   queue_destroy(lista_xy);
} 
开发者ID:i5o,项目名称:paint-activity,代码行数:56,代码来源:eggfill.c


示例4: queue_invert

void
queue_invert (queue *q)
{
    if (queue_is_empty(q))
        return;

    pos c = queue_dequeue(q);
    queue_invert(q);
    queue_enqueue(q, c);
}
开发者ID:skewerr,项目名称:cmddisplay,代码行数:10,代码来源:queue.c


示例5: queue_insert_node

static void queue_insert_node(Queue *queue, 
						struct node *key) {
	if (queue_is_empty(queue)) {
		queue->head = key;
		queue->tail = key;
	} else {
		queue->tail->next = key;
		queue->tail = key;
	}
}
开发者ID:dkuner,项目名称:dict,代码行数:10,代码来源:queue.c


示例6: btn_getkey

/*!
  * \brief
  *    Returns the key to the caller.
  *    If we have bt_wait flag set, it waits for the user choice.
  *
  * \param  wait  Wait for key flag
  * \retval key pressed or -1(EOF) if none.
  */
keys_t btn_getkey (uint8_t wait)
{
   keys_t ret=BTN_NULL;

   // wait for user's action
   while (wait && queue_is_empty (&btn_q))
      ;
   queue_get (&btn_q, (void*)&ret);
   return ret;
}
开发者ID:hoo2,项目名称:toolbox,代码行数:18,代码来源:buttons.c


示例7: while

void *recExec() {
	while (1) {
		if (!queue_is_empty(pColaReady) && !queue_is_empty(pColaCpu)) {

			sem_wait(&mut_r);
			ptmp = queue_pop(pColaReady);
			sem_post(&mut_r);
			sem_wait(&mut_c);
			pcpu = queue_pop(pColaCpu);
			sem_post(&mut_c);
			ptmp->cpuexec = pcpu;

			//printf("Exec  proceso %d tiempo cpu %d\n",ptmp->pid,tact);
			sem_wait(&mut_e);
			queue_push(pColaExec, ptmp);
			sem_post(&mut_e);
		}
	}
}
开发者ID:alanhala,项目名称:so-atalo-con-hilos,代码行数:19,代码来源:nucleohilos.c


示例8: queue_get

/*!
  * \brief
  *   This function gets a byte from queue.
  * \param  pointer to byte
  * \return
  *   \arg  0  Empty queue
  *   \arg  1  Done
 */
__Os__ int queue_get (queue_t *queue, void *b)
{
   if ( queue_is_empty (queue) )    //Empty queue
      return 0;
   memcpy (b, (const void*)&queue->buf[queue->head*queue->item_size], queue->item_size);
   //rotate pointers
   if ( ++queue->head >= queue->items )
      queue->head = 0;
   return 1;
}
开发者ID:supernlogn,项目名称:toolbox,代码行数:18,代码来源:queue.c


示例9: playlist_update_queued_song

void
playlist_update_queued_song(struct playlist *playlist,
			    struct player_control *pc,
			    const struct song *prev)
{
	int next_order;
	const struct song *next_song;

	if (!playlist->playing)
		return;

	assert(!queue_is_empty(&playlist->queue));
	assert((playlist->queued < 0) == (prev == NULL));

	next_order = playlist->current >= 0
		? queue_next_order(&playlist->queue, playlist->current)
		: 0;

	if (next_order == 0 && playlist->queue.random &&
	    !playlist->queue.single) {
		/* shuffle the song order again, so we get a different
		   order each time the playlist is played
		   completely */
		unsigned current_position =
			queue_order_to_position(&playlist->queue,
						playlist->current);

		queue_shuffle_order(&playlist->queue);

		/* make sure that the playlist->current still points to
		   the current song, after the song order has been
		   shuffled */
		playlist->current =
			queue_position_to_order(&playlist->queue,
						current_position);
	}

	if (next_order >= 0)
		next_song = queue_get_order(&playlist->queue, next_order);
	else
		next_song = NULL;

	if (prev != NULL && next_song != prev) {
		/* clear the currently queued song */
		pc_cancel(pc);
		playlist->queued = -1;
	}

	if (next_order >= 0) {
		if (next_song != prev)
			playlist_queue_song_order(playlist, pc, next_order);
		else
			playlist->queued = next_order;
	}
}
开发者ID:pallotron,项目名称:MPD,代码行数:55,代码来源:playlist.c


示例10: queue_get_ptr

uint32_t queue_get_ptr(queue_t * queue, uint8_t ** element)
{
    if (queue_is_empty(queue))
        return ERROR_NOT_FOUND;

    *element = &queue->elements[queue->head * queue->element_size];

    queue->head = (queue->head + 1u) % queue->size;

    return SUCCESS;
}
开发者ID:oyv,项目名称:nrf51-simple-radio,代码行数:11,代码来源:queue.c


示例11: queue_cleanup

void queue_cleanup(queue* q)
{
    while(!queue_is_empty(q)){
	queue_pop(q);
    }

    free(q->array);
    sem_destroy(q->content_sem);
    sem_destroy(q->freespace_sem);
    pthread_mutex_destroy(q->mutex);
}
开发者ID:Raizex,项目名称:CU-CS3753-PA2,代码行数:11,代码来源:queue.c


示例12: queue_free

void queue_free (Queue* queue) {
  /* Empty the queue */

  while (!queue_is_empty (queue)) {
    queue_pop_head (queue);
    }

  /* Free back the queue */

  free (queue);
  }
开发者ID:dlove24,项目名称:dl-calg,代码行数:11,代码来源:queue.c


示例13: queue_remove

//-----------------------------------------------------------------
//  need to use free() to free up memory
//-----------------------------------------------------------------
boolean_t queue_remove(queue_t q, queue_element_t * e) {
    queue_link_t oldHead;
    assert(q != NULL);
    if(queue_is_empty(q))
        return FALSE;
    *e = q->head->e;
    oldHead = q->head;
    q->head = q->head->next;

    return TRUE;
}
开发者ID:cyruserfani,项目名称:programs,代码行数:14,代码来源:queue.c


示例14: empty_queue

bool empty_queue(Queue *self) {
	if (!self) {
		return false;
	}
	while (!queue_is_empty(self)) {
		int *popped = queue_pop_tail(self);
		//printf("popped %d from queue\n", *popped);
		free(popped);
	}
	return true;
}
开发者ID:Jeremalloch,项目名称:EMG-ECG-Signal-Processing-Library,代码行数:11,代码来源:queue.c


示例15: main

int main()
{
	int i;
	queue q = queue_create();
	assert(queue_is_empty(q));
	queue_enqueue(q, 3);
	assert(queue_dequeue(q) == 3);
	assert(queue_is_empty(q));
	for (i= 0; i < 99; i++) {
		queue_enqueue(q, i);
	}
	assert(queue_is_full(q));
	assert(queue_dequeue(q) == 0);
	queue_enqueue(q, 1);
	queue_enqueue(q, 1);
	assert(queue_is_full(q));
	queue_destroy(&q);
	assert(q == NULL);
	return 0;
}
开发者ID:booirror,项目名称:data-structures-and-algorithm-in-c,代码行数:20,代码来源:circular_queue_test.c


示例16: queue_reverse

void queue_reverse(queue* q) {
  assert(q != NULL);

  // If empty, do nothing.
  if (queue_is_empty(q)) {
    return;
  }

  queue_link* end = queue_reverse_helper(q, q->head);
  end->next = NULL;
}
开发者ID:creisman,项目名称:os,代码行数:11,代码来源:queue.c


示例17: printf

/*
 * Dequeueing.
 */
void *dequeue() {
    if(queue_is_empty()) {
        printf("Fatal error: The queue is empty.\n");
        exit(-1);
    }

    void *item;
    item = queue[out_index];
    out_index = (out_index+1) % memory_size;
    return item;
}
开发者ID:orumin,项目名称:Graph,代码行数:14,代码来源:queue.c


示例18: h2o_http2_scheduler_run

int h2o_http2_scheduler_run(h2o_http2_scheduler_node_t *root, h2o_http2_scheduler_run_cb cb, void *cb_arg)
{
    if (root->_queue != NULL) {
        while (!queue_is_empty(root->_queue)) {
            int bail_out = proceed(root, cb, cb_arg);
            if (bail_out)
                return bail_out;
        }
    }
    return 0;
}
开发者ID:pmeenan,项目名称:h2o,代码行数:11,代码来源:scheduler.c


示例19: queue_get

uint32_t queue_get(queue_t * queue, uint8_t * element)
{
    if (queue_is_empty(queue))
        return ERROR_NOT_FOUND;

    memcpy(element, &queue->elements[queue->head * queue->element_size], queue->element_size);

    queue->head = (queue->head + 1u) % queue->size;

    return SUCCESS;
}
开发者ID:hlnd,项目名称:nrf51-simple-radio,代码行数:11,代码来源:queue.c


示例20: async_queue_timed_pop_unlocked

static void *
async_queue_timed_pop_unlocked(UAsyncQueue *queue, uint64_t end_time)
{
    if (queue_is_empty(queue->queue)) {
        assert(!queue->is_waiting);
        ++queue->is_waiting;
        if (!end_time)
            pthread_cond_wait(&queue->cond, &queue->mutex);
        else {
            struct timespec timeout;
            timeout.tv_sec  = end_time / 1000000;
            timeout.tv_nsec = 1000 * (end_time % 1000000);
            pthread_cond_timedwait(&queue->cond, &queue->mutex, &timeout);
        }
        --queue->is_waiting;
        if (queue_is_empty(queue->queue))
            return NULL;
    }
    return queue_pop(queue->queue);
}
开发者ID:elFarto,项目名称:libva-vdpau-driver,代码行数:20,代码来源:uasyncqueue.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ queue_isempty函数代码示例发布时间:2022-05-30
下一篇:
C++ queue_init函数代码示例发布时间: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