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


C++ pqueue_pop函数代码示例

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


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

示例1: dtls1_clear_queues

static void dtls1_clear_queues(SSL *s)
{
    pitem *item = NULL;
    DTLS1_RECORD_DATA *rdata;

    while ((item = pqueue_pop(s->d1->unprocessed_rcds.q)) != NULL) {
        rdata = (DTLS1_RECORD_DATA *)item->data;
        if (rdata->rbuf.buf) {
            OPENSSL_free(rdata->rbuf.buf);
        }
        OPENSSL_free(item->data);
        pitem_free(item);
    }

    while ((item = pqueue_pop(s->d1->processed_rcds.q)) != NULL) {
        rdata = (DTLS1_RECORD_DATA *)item->data;
        if (rdata->rbuf.buf) {
            OPENSSL_free(rdata->rbuf.buf);
        }
        OPENSSL_free(item->data);
        pitem_free(item);
    }

    while ((item = pqueue_pop(s->d1->buffered_app_data.q)) != NULL) {
        rdata = (DTLS1_RECORD_DATA *)item->data;
        if (rdata->rbuf.buf) {
            OPENSSL_free(rdata->rbuf.buf);
        }
        OPENSSL_free(item->data);
        pitem_free(item);
    }

    dtls1_clear_received_buffer(s);
    dtls1_clear_sent_buffer(s);
}
开发者ID:derekmarcotte,项目名称:freebsd,代码行数:35,代码来源:d1_lib.c

示例2: main

int
main(void)
	{
	pitem *item;
	pqueue pq;

	pq = pqueue_new();

	item = pitem_new(3, NULL);
	pqueue_insert(pq, item);

	item = pitem_new(1, NULL);
	pqueue_insert(pq, item);

	item = pitem_new(2, NULL);
	pqueue_insert(pq, item);

	item = pqueue_find(pq, 1);
	fprintf(stderr, "found %ld\n", item->priority);

	item = pqueue_find(pq, 2);
	fprintf(stderr, "found %ld\n", item->priority);

	item = pqueue_find(pq, 3);
	fprintf(stderr, "found %ld\n", item ? item->priority: 0);

	pqueue_print(pq);

	for(item = pqueue_pop(pq); item != NULL; item = pqueue_pop(pq))
		pitem_free(item);

	pqueue_free(pq);
	return 0;
	}
开发者ID:0b10011,项目名称:node,代码行数:34,代码来源:pq_test.c

示例3: main

int main(void)
{
	int i;
	int p;

	pqueue_t *pq;
	node_t   *ns;
	node_t   *n;

	/* We will need (N + 1) slots in "pris" vector. Extra one slot for spare
	 * usages. */
	pris = malloc(5 * sizeof(int *));
	for (i = 0; i < 5; i++)
		pris[i] = malloc(2 * sizeof(int));

	pris[0][0] = 4; pris[0][1] = 2;
	pris[1][0] = 3; pris[1][1] = 7;
	pris[2][0] = 3; pris[2][1] = 1;
	pris[3][0] = 5; pris[3][1] = 6;
	p = 4;									/* Initialize spare slot. */

	pq = pqueue_init(10, cmp_pri, get_pri, set_pri, get_pos, set_pos);
	ns = malloc(4 * sizeof(node_t));

	ns[0].pri = 0; ns[0].val = 0; pqueue_insert(pq, &ns[0]);
	ns[1].pri = 1; ns[0].val = 1; pqueue_insert(pq, &ns[1]);
	ns[2].pri = 2; ns[0].val = 2; pqueue_insert(pq, &ns[2]);
	ns[3].pri = 3; ns[0].val = 3; pqueue_insert(pq, &ns[3]);

	printf("initial:\n"); pqueue_print(pq, stdout, pr_node);

	n = pqueue_pop(pq);
	printf("[pop] pri: %d, val: %d, real-pri: [%d %d]\n",
		   n->pri, n->val, pris[n->pri][0], pris[n->pri][1]);
	printf("after first pop:\n"); pqueue_print(pq, stdout, pr_node);

	pris[p][0] = 3; pris[p][1] = 0;
	pqueue_change_priority(pq, p, &ns[3]);	/* 3: (5,6) -> (3,0) */
	p = 3;									/* Move spare slot to 3. */
	printf("after 3: (5,6) -> (3,0):\n"); pqueue_print(pq, stdout, pr_node);

	pris[p][0] = 3; pris[p][1] = -1;
	pqueue_change_priority(pq, p, &ns[0]);	/* 0: (4,2) -> (3,-1) */
	p = 0;									/* Move spare slot to 0. */
	printf("after 0: (4,2) -> (3,-1):\n"); pqueue_print(pq, stdout, pr_node);

	while ((n = pqueue_pop(pq)))
		printf("[pop] pri: %d, val: %d, real-pri: [%d %d]\n",
			   n->pri, n->val, pris[n->pri][0], pris[n->pri][1]);

	pqueue_free(pq);
	free(ns);
	free(pris);

	return 0;
}
开发者ID:machicao2013,项目名称:recipes,代码行数:56,代码来源:sample-multiattr.c

示例4: dtls1_clear_queues

static void dtls1_clear_queues(SSL *s)
	{
    pitem *item = NULL;
    hm_fragment *frag = NULL;
	DTLS1_RECORD_DATA *rdata;

    while( (item = pqueue_pop(s->d1->unprocessed_rcds.q)) != NULL)
        {
		rdata = (DTLS1_RECORD_DATA *) item->data;
		if (rdata->rbuf.buf)
			{
			OPENSSL_free(rdata->rbuf.buf);
			}
        OPENSSL_free(item->data);
        pitem_free(item);
        }

    while( (item = pqueue_pop(s->d1->processed_rcds.q)) != NULL)
        {
		rdata = (DTLS1_RECORD_DATA *) item->data;
		if (rdata->rbuf.buf)
			{
			OPENSSL_free(rdata->rbuf.buf);
			}
        OPENSSL_free(item->data);
        pitem_free(item);
        }

    while( (item = pqueue_pop(s->d1->buffered_messages)) != NULL)
        {
        frag = (hm_fragment *)item->data;
        OPENSSL_free(frag->fragment);
        OPENSSL_free(frag);
        pitem_free(item);
        }

    while ( (item = pqueue_pop(s->d1->sent_messages)) != NULL)
        {
        frag = (hm_fragment *)item->data;
        OPENSSL_free(frag->fragment);
        OPENSSL_free(frag);
        pitem_free(item);
        }

	while ( (item = pqueue_pop(s->d1->buffered_app_data.q)) != NULL)
		{
		rdata = (DTLS1_RECORD_DATA *) item->data;
		if (rdata->rbuf.buf)
			{
			OPENSSL_free(rdata->rbuf.buf);
			}
		OPENSSL_free(item->data);
		pitem_free(item);
		}
	}
开发者ID:AmineToujani,项目名称:openssl,代码行数:55,代码来源:d1_lib.c

示例5: dtls1_clear_record_buffer

/* call this function when the buffered messages are no longer needed */
void
dtls1_clear_record_buffer(SSL *s)
	{
	pitem *item;

	for(item = pqueue_pop(s->d1->sent_messages);
		item != NULL; item = pqueue_pop(s->d1->sent_messages))
		{
		dtls1_hm_fragment_free((hm_fragment *)item->data);
		pitem_free(item);
		}
	}
开发者ID:aosm,项目名称:OpenSSL098,代码行数:13,代码来源:d1_both.c

示例6: dtls1_free

void dtls1_free(SSL *s)
	{
    pitem *item = NULL;
    hm_fragment *frag = NULL;

	ssl3_free(s);

    while( (item = pqueue_pop(s->d1->unprocessed_rcds.q)) != NULL)
        {
        OPENSSL_free(item->data);
        pitem_free(item);
        }
    pqueue_free(s->d1->unprocessed_rcds.q);

    while( (item = pqueue_pop(s->d1->processed_rcds.q)) != NULL)
        {
        OPENSSL_free(item->data);
        pitem_free(item);
        }
    pqueue_free(s->d1->processed_rcds.q);

    while( (item = pqueue_pop(s->d1->buffered_messages)) != NULL)
        {
        frag = (hm_fragment *)item->data;
        OPENSSL_free(frag->fragment);
        OPENSSL_free(frag);
        pitem_free(item);
        }
    pqueue_free(s->d1->buffered_messages);

    while ( (item = pqueue_pop(s->d1->sent_messages)) != NULL)
        {
        frag = (hm_fragment *)item->data;
        OPENSSL_free(frag->fragment);
        OPENSSL_free(frag);
        pitem_free(item);
        }
	pqueue_free(s->d1->sent_messages);

	while ( (item = pqueue_pop(s->d1->buffered_app_data.q)) != NULL)
		{
		frag = (hm_fragment *)item->data;
		OPENSSL_free(frag->fragment);
		OPENSSL_free(frag);
		pitem_free(item);
		}
	pqueue_free(s->d1->buffered_app_data.q);

	OPENSSL_free(s->d1);
	}
开发者ID:dienbk7x,项目名称:NetmfSTM32,代码行数:50,代码来源:d1_lib.cpp

示例7: test_push_existing

static void test_push_existing()
{
	size_t i, j;
	int top;
	struct pqueue pq;
	int elt;

	for (i = 0; i < count; i++) {
		pqueue_init_copy(&pq, &pqueue);
		elt = elts[i];

		pqueue_push(&pq, &elt);

		assert_int_equal(pqueue_count(&pq), count + 1);

		for (j = 0; j < count + 1; j++) {
			top = *(int *)pqueue_top(&pq);
			pqueue_pop(&pq);
			if (j <= i) {
				assert_int_equal(top, elts[j]);
			} else {
				assert_int_equal(top, elts[j - 1]);
			}
		}

		pqueue_destroy(&pq);
	}
}
开发者ID:patperry,项目名称:core,代码行数:28,代码来源:pqueue-test.c

示例8: T_TEST

} T_END_TEST

T_TEST(t_pqueue_alt_insert) {
	struct pqueue* q = pqueue_create(comp);
	int i;
	int num = 10;

	T_ASSERT(q);

	for (i = 0; i < num; i++) {
		T_ASSERT(0 == pqueue_insert(q, (void*)((i % 2) ? i : num - i - (num % 2 ? 1 : 2))));
	}
	
	T_ASSERT(!pqueue_is_empty(q));

	i = 0;
	while (!pqueue_is_empty(q)) {
		T_ASSERT(i == (int)pqueue_peek(q));
		T_ASSERT(i == (int)pqueue_pop(q));
		i++;
	}

	T_ASSERT(i == num);

	pqueue_destroy(q);
} T_END_TEST
开发者ID:m3lawren,项目名称:libm3,代码行数:26,代码来源:pqueue_test.c

示例9: process_data_samples

void process_data_samples(uint64_t time) {
   if(!data_events)
      return;

   struct data_ev *event = pqueue_peek(data_events);
   while(event && event->rdt <= time) {
      /*printf("%s:%lu:%p:%s\n", event->type==MALLOC?"malloc":"free", event->rdt, (void*)event->free.begin,
            event->type==MALLOC?event->malloc.info:"");*/
      if(event->type==MALLOC) {
         void * data = rbtree_lookup(active_data, (void*)event->free.begin, pointer_cmp_reverse);
         if(data) {
            //printf("#Variable inserted twice ?!\n");
            ((struct data_ev *)data)->malloc.end = event->malloc.end;
            data_fail++;
         } else {
            rbtree_insert(active_data, (void*)event->malloc.begin, event, pointer_cmp_reverse);
            data_success++;
         }
      } else if(event->type==FREE) {
         void * data = rbtree_lookup(active_data, (void*)event->free.begin, pointer_cmp_reverse);
         if(!data) {
            //printf("#Free of unknown pointer!\n");
            data_fail++;
         } else {
            rbtree_delete(active_data, (void*)event->free.begin, pointer_cmp_reverse);
            data_success++;
         }
      }

      processed_data_samples++;
      pqueue_pop(data_events);
      event = pqueue_peek(data_events);
   }
}
开发者ID:Memprof,项目名称:parser,代码行数:34,代码来源:data.bis.c

示例10: dtls1_clear_queues

static void dtls1_clear_queues(SSL *s) {
  pitem *item = NULL;
  hm_fragment *frag = NULL;

  while ((item = pqueue_pop(s->d1->buffered_messages)) != NULL) {
    frag = (hm_fragment *)item->data;
    dtls1_hm_fragment_free(frag);
    pitem_free(item);
  }

  while ((item = pqueue_pop(s->d1->sent_messages)) != NULL) {
    frag = (hm_fragment *)item->data;
    dtls1_hm_fragment_free(frag);
    pitem_free(item);
  }
}
开发者ID:friends110110,项目名称:boringssl,代码行数:16,代码来源:d1_lib.c

示例11: dtls1_free

void dtls1_free(SSL *s)
	{
    pitem *item = NULL;
    hm_fragment *frag = NULL;

	ssl3_free(s);

    while( (item = pqueue_pop(s->d1->unprocessed_rcds.q)) != NULL)
        {
        OPENSSL_free(item->data);
        pitem_free(item);
        }
    pqueue_free(s->d1->unprocessed_rcds.q);

    while( (item = pqueue_pop(s->d1->processed_rcds.q)) != NULL)
        {
        OPENSSL_free(item->data);
        pitem_free(item);
        }
    pqueue_free(s->d1->processed_rcds.q);

    while( (item = pqueue_pop(s->d1->buffered_messages)) != NULL)
        {
        frag = (hm_fragment *)item->data;
        OPENSSL_free(frag->fragment);
        OPENSSL_free(frag);
        pitem_free(item);
        }
    pqueue_free(s->d1->buffered_messages);

    while ( (item = pqueue_pop(s->d1->sent_messages)) != NULL)
        {
        frag = (hm_fragment *)item->data;
        OPENSSL_free(frag->fragment);
        OPENSSL_free(frag);
        pitem_free(item);
        }
	pqueue_free(s->d1->sent_messages);

	pq_64bit_free(&(s->d1->bitmap.map));
	pq_64bit_free(&(s->d1->bitmap.max_seq_num));

	pq_64bit_free(&(s->d1->next_bitmap.map));
	pq_64bit_free(&(s->d1->next_bitmap.max_seq_num));

	OPENSSL_free(s->d1);
	}
开发者ID:siredblood,项目名称:tree-bumpkin-project,代码行数:47,代码来源:d1_lib.c

示例12: main

int main (int argc, char *argv[])
{
	int i;
	struct pqueue *pqueue;
	pqueue = pqueue_create(0, compare, NULL);
	if (pqueue == NULL) {
		return -1;
	}
	for (i = 1; i < argc; i++) {
		pqueue_insert(pqueue, argv[i]);
	}
	printf("%s ", (char *) pqueue_pop(pqueue));
	printf("%s ", (char *) pqueue_pop(pqueue));
	printf("%s ", (char *) pqueue_pop(pqueue));
	pqueue_destroy(pqueue);
	return 0;
}
开发者ID:alperakcan,项目名称:algorithms,代码行数:17,代码来源:pqueue-00.c

示例13: DTLS_RECORD_LAYER_clear

void DTLS_RECORD_LAYER_clear(RECORD_LAYER *rl)
{
    DTLS_RECORD_LAYER *d;
    pitem *item = NULL;
    DTLS1_RECORD_DATA *rdata;
    pqueue unprocessed_rcds;
    pqueue processed_rcds;
    pqueue buffered_app_data;

    d = rl->d;
    
    while ((item = pqueue_pop(d->unprocessed_rcds.q)) != NULL) {
        rdata = (DTLS1_RECORD_DATA *)item->data;
        if (rdata->rbuf.buf) {
            OPENSSL_free(rdata->rbuf.buf);
        }
        OPENSSL_free(item->data);
        pitem_free(item);
    }

    while ((item = pqueue_pop(d->processed_rcds.q)) != NULL) {
        rdata = (DTLS1_RECORD_DATA *)item->data;
        if (rdata->rbuf.buf) {
            OPENSSL_free(rdata->rbuf.buf);
        }
        OPENSSL_free(item->data);
        pitem_free(item);
    }

    while ((item = pqueue_pop(d->buffered_app_data.q)) != NULL) {
        rdata = (DTLS1_RECORD_DATA *)item->data;
        if (rdata->rbuf.buf) {
            OPENSSL_free(rdata->rbuf.buf);
        }
        OPENSSL_free(item->data);
        pitem_free(item);
    }

    unprocessed_rcds = d->unprocessed_rcds.q;
    processed_rcds = d->processed_rcds.q;
    buffered_app_data = d->buffered_app_data.q;
    memset(d, 0, sizeof *d);
    d->unprocessed_rcds.q = unprocessed_rcds;
    d->processed_rcds.q = processed_rcds;
    d->buffered_app_data.q = buffered_app_data;
}
开发者ID:VaryJames,项目名称:Sample,代码行数:46,代码来源:rec_layer_d1.c

示例14: sweep_line_delete

static inline void
sweep_line_delete (sweep_line_t	*sweep,
		   rectangle_t	*rectangle,
		   cairo_boxes_t *out)
{
    sweep_line_delete_edge (sweep, &rectangle->left, out);
    sweep_line_delete_edge (sweep, &rectangle->right, out);

    pqueue_pop (&sweep->pq);
}
开发者ID:Happy-Ferret,项目名称:webkit.js,代码行数:10,代码来源:cairo-boxes-intersect.cpp

示例15: dtls1_retrieve_buffered_fragment

static int
dtls1_retrieve_buffered_fragment(SSL *s, long max, int *ok)
	{
	/* (0) check whether the desired fragment is available
	 * if so:
	 * (1) copy over the fragment to s->init_buf->data[]
	 * (2) update s->init_num
	 */
	pitem *item;
	hm_fragment *frag;
	int al;

	*ok = 0;
	item = pqueue_peek(s->d1->buffered_messages);
	if ( item == NULL)
		return 0;

	frag = (hm_fragment *)item->data;
	
	/* Don't return if reassembly still in progress */
	if (frag->reassembly != NULL)
		return 0;

	if ( s->d1->handshake_read_seq == frag->msg_header.seq)
		{
		unsigned long frag_len = frag->msg_header.frag_len;
		pqueue_pop(s->d1->buffered_messages);

		al=dtls1_preprocess_fragment(s,&frag->msg_header,max);

		if (al==0) /* no alert */
			{
			unsigned char *p = (unsigned char *)s->init_buf->data+DTLS1_HM_HEADER_LENGTH;
			memcpy(&p[frag->msg_header.frag_off],
				frag->fragment,frag->msg_header.frag_len);
			}

		dtls1_hm_fragment_free(frag);
		pitem_free(item);

		if (al==0)
			{
			*ok = 1;
			return frag_len;
			}

		ssl3_send_alert(s,SSL3_AL_FATAL,al);
		s->init_num = 0;
		*ok = 0;
		return -1;
		}
	else
		return 0;
	}
开发者ID:aosm,项目名称:OpenSSL098,代码行数:54,代码来源:d1_both.c


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