C language implementation of non-cyclic double linked table node deletion (leading node end node)

Source: Internet
Author: User

I am in the previous blog "C language implementation of the non-cyclic double linked table node deletion (not the lead node)" in detail in the double linked list without the head and tail node to delete a node, the processing process or slightly trouble. Since we've learned to work with a two-linked list using a back-and-tail node, the removal process is very convenient. Code uploaded to Https://github.com/chenyufeng1991/DeleteNodeDoubleLinkedList_HeadList.

The core code is as follows:

Deletes the node int deleteposlist of the POS location (Nodes *phead,node *ptail,int pos) {int i = 1;
    Node *pmove;
    Pmove = phead->next;
            while (Pmove!= ptail) {if (i = = pos) {Pmove->prior->next = pmove->next;
            Pmove->next->prior = pmove->prior;
            Free (pmove);
            Pmove = NULL;
            printf ("%s function execution, delete pos=%d location node succeeded \ \", __function__,pos);
        return 1;
        } i++;
    Pmove = pmove->next;
    printf ("%s function execution, deletion of node in pos=%d location failed \ \", __function__,pos);
return 0;
    //delete the node with a value of x, and if the node is present, remove the int deletevaluelist (node *phead,node *ptail,int x) {node *pmove;
    Pmove = phead->next;
            while (Pmove!= ptail) {if (pmove->element = = x) {Pmove->prior->next = pmove->next;
            Pmove->next->prior = pmove->prior;
            Free (pmove);
            Pmove = NULL;
            printf ("%s function execution, deletion of x=%d node succeeded \ \", __function__,x);
     return 1;   } Pmove = pmove->next;
    printf ("%s function execution, deletion of node with X" failed \ n ", __function__);
return 0; }


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.