Пример #1
0
int main()
{
    DuLinkList La;
    InitList_DuL(La);
    ElemType e;
    printf("Assigment for La:\n");
    CreateList_DuL(La,5);
    printf("The elements in La:\n");
    ListTraverse_DuL(La,Display_DuL);
    ListDelete_DuL(La, 2, e);
    printf("We have deleted the 2th element in La:\n");
    ListTraverse_DuL(La,Display_DuL);
    ListInsert_DuL(La, 2, e);
    printf("Put the element deleted in the proier statement in 2th:\n");
    ListTraverse_DuL(La,Display_DuL);
}
Пример #2
0
Status MergeList_DuL( DuLinkList& La , DuLinkList& Lb , DuLinkList& Lc , PFCOMPARE cmp )
{
	int ret = 0;
	if( OK != ( ret = InitList_DuL(Lc) ) )
	{
		return ret;
	}


	while( GetHead_DuL(La) && GetHead_DuL(Lb) )
	{
		LP_DuLNode pa = GetHead_DuL(La);
		LP_DuLNode pb = GetHead_DuL(Lb);

		if( L_LESS_R == cmp(pa->data , pb->data ) )
		{
			DelFirst_DuL( La , pa );
			Append_DuL( Lc , pa );
		}else{
			DelFirst_DuL(Lb , pb);
			Append_DuL( Lc , pb);
		} 
	}

	while(  GetHead_DuL(La) )
	{
		LP_DuLNode pa = NULL;
		DelFirst_DuL(La , pa);
		Append_DuL( Lc , pa ); 
	}

	while( GetHead_DuL(Lb) )
	{
		LP_DuLNode  pb = NULL;
		DelFirst_DuL(Lb , pb);
		Append_DuL( Lc , pb ); 
	}
	 
	return OK;
}