Exemplo n.º 1
0
VDLIST_API void VDLIST_CDECL delete_vdlist(
	vdlist_t* vdlist)
{
	
	vdlist_node_t * head = vdlist->head;
	vdlist_node_t * tmp = 0;

	while (head) {
		tmp=head;
		head = head->next;
		VFREE(vdlist, tmp, vdlist_node_t);
	}

	VFREE(vdlist, vdlist, vdlist_t);
	
}
Exemplo n.º 2
0
VDLIST_API void VDLIST_CDECL vdlist_flush(
	vdlist_t* vdlist)
{
	while (vdlist->head) {
		vdlist_node_t* node = vdlist->head;
		vdlist->head = node->next;
		VFREE(vdlist, node, vdlist_node_t);
	}

	vdlist->head = 0;
	vdlist->tail = 0;
	vdlist->cursor = 0;
	vdlist->cursor_index = 0;
	vdlist->count = 0;
}
Exemplo n.º 3
0
VDLIST_API int VDLIST_CDECL vdlist_remove(
	vdlist_t* vdlist, 
	void* item)
{
	vdlist_node_t* node = vdlist->head;

	while (node) {


		if(node ->item == item){

			if(vdlist->head == node)
			{
				vdlist->head = node->next;
				vdlist->head->prev = 0;
			}

				else if (vdlist->tail==node)
				{
					vdlist->tail = node->prev;
					vdlist->tail->next = 0;

				}

					else
					{
						node->prev->next = node->next;
						node->next->prev = node->prev;


					}


			VFREE(vdlist, node, vdlist_node_t);
			vdlist->count--; 
			VDLIST_RESET_CURSOR(vdlist)
			return 1;



		}

		node=node->next;  /* traverse the list */
	}
	return 0;
}
Exemplo n.º 4
0
VDLIST_API void * VDLIST_CDECL vdlist_remove_at_cursor(
	vdlist_t* vdlist)
{
	vdlist_node_t* cursor = vdlist->cursor;
	vdlist_node_t* node;
	void * item;
	
	if (!cursor) return 0;

	if (vdlist->cursor->prev)
		vdlist->cursor->prev->next = cursor->next;

	item = cursor->item;
	if (vdlist->tail == cursor) 
        vdlist->tail = vdlist->cursor->prev;
	if (vdlist->head == cursor)
		vdlist->head = cursor->next;
	node = cursor;
    vdlist->cursor = cursor->next;
	VFREE(vdlist, node, vdlist_node_t);
	vdlist->count--; 
	return item;
}
Exemplo n.º 5
0
VDLIST_API void * VDLIST_CDECL vdlist_remove_first(
	vdlist_t* vdlist)
{
	vdlist_node_t* node = vdlist->head;
	void * item;
	
	if (!vdlist->head) return 0;

	vdlist->head = node->next;

						/* added  for doubly linked list */
						vdlist->head->prev = 0;

	item = node->item;

	VFREE(vdlist, node, vdlist_node_t);
	vdlist->count--; 

	if (!vdlist->head) vdlist->tail = 0;

	VDLIST_RESET_CURSOR(vdlist)
	return item;
}
Exemplo n.º 6
0
/* B := inv(A), both A and B are real matrices of rank x rank */
void Minv (int rank, double A[], double B[])
{
    int info, *ipiv;
    double *a, *work;
    a = Mmem(rank*rank);
    work = Vmem(rank);
    ipiv = VImem(rank);
    memcpy (a, A, (long)rank*rank*sizeof(double));
    FORTRAN_SYMBOL(dgetrf) (&rank, &rank, a, &rank, ipiv, &info);
    if ( info != 0 )
    {
	printf ("error: Minv: matrix of rank %d is singular.\n",
		rank);
	mump(rank,A);
	exit(1);
    }
    FORTRAN_SYMBOL(dgetri) (&rank, a, &rank, ipiv, work, &rank, &info);
    memcpy (B, a, (long)rank*rank*sizeof(double));
    VFREE (ipiv);
    Vfree (work);
    Mfree (a);
    return;
} /* end Minv() */
Exemplo n.º 7
0
VDLIST_API void * VDLIST_CDECL vdlist_remove_cursor_next(
	vdlist_t* vdlist)
{
    vdlist_node_t* cursor = vdlist->cursor;
	vdlist_node_t* node;
	void * item;
	
	if (!cursor) return 0;
	if (!cursor->next) return 0;
    node = cursor->next;
	item = node->item;
	if (vdlist->tail == node) 
        vdlist->tail = cursor;
    cursor->next = node->next;

							
		/* added  for doubly linked list */
		   cursor->next->prev = cursor;


	VFREE(vdlist, node, vdlist_node_t);
	vdlist->count--; 
	return item;
}