Exemplo n.º 1
0
int sfqdfull_add_item_to_queue(struct generic_queue_item* item)
{
	int dispatched=0;

	if (SFQD_FULL_USE_HEAP_QUEUE==1)
	{

		struct heap_node* hn = malloc(sizeof(struct heap_node));
		heap_node_init(hn, item);
		heap_insert(sfqdfull_packet_cmp, sfqdfull_heap_queue, hn);

	}
	else
	{
		if  (PINT_llist_add_to_tail(
				sfqdfull_llist_queue,
		    item))
		{

			fprintf(stderr,"sfqd_full queue insertion error!\n");
			exit(-1);
		}


	}
	return dispatched;
}
Exemplo n.º 2
0
/* vloz hranu do haldy */
void heap_insert(struct heap* h, int key, int src, int dst)
{
	struct heap_node * node;
	struct edge * e;
	
	node = (struct heap_node *) malloc(sizeof(struct heap_node));
	e    = (struct edge *) malloc(sizeof(struct edge));
	
	e->src        = src;
	e->dst        = dst;
	e->price      = key;
	e->mod        = 0;
	e->node       = NULL;
	heap_node_init(node, key, e);
	
	node->child  = NULL;
	node->parent = NULL;
	node->next   = NULL;
	node->degree = 0;
	
	__heap_union(h, node);
}