Universal Linked List Implementation (refer to Linux List)

Source: Internet
Author: User

Recently, when referring to the universal two-way linked list implemented by Linux, because typeof is not a keyword specified by standard c, other compilers except the GCC compiler may not support typeof keywords, therefore, the Linux linked list is not flexible in usage. It requires that the connector, that is, the linked list structure, be used as the first element of the user-defined struct, embedded detailed comments.

IList. h

   _I_LIST_H_2012_11_23_              typedef        _IList *      _IList * }IList, *           IList_Foreach(pList, pos) \              pos = pos = (pList)->         pos !=         pos = pos->            IList_Foreach_Salf(pList, temp, pos) \              pos = (pList)->_next, temp = pos->         pos !=         pos = temp, temp = pos->                                                                                                                               pIList IList_Nth(pIList pList,                   

IList. c

 #include <stdio.h> #include         pList->_prev =     pList->_next =         pNewLink->_prev = pLink->     pNewLink->_next =     pNewLink->_prev->_next =     pNewLink->_next->_prev =              IList_Insert(pList->         pLink->_prev->_next = pLink->     pLink->_next->_prev = pLink->          pList->_next != pList ? pList->          pList->_prev != pList ? pList->          pList->_next ==          count =      pIList temp =       (pList->_next ==                      count ++                 pLink->_next != pList ? pLink->          pLink->_prev != pList ? pLink->   pIList IList_Nth(pIList pList,       pIList pLink =      count =             count ++          (count ==                             pIList pTemp =      index =       pTemp =       ((pTemp != NULL) && (pTemp !=          index++         pTemp =        (pTemp ==          (-               }

IListTest. c

#include <stdio.h><stdlib.h><.h> ** main( argc,  * i =  num =  count = = (argc > = atoi(argv[= (IList *)malloc( (! -,  (i = ; i < num; i ++= malloc( (! -, ->_id = i + &temp->=, temp->, &=, count, ((pStudent)link)->, ((pStudent)link)->     ( 

 

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.