list.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * Summary: lists interfaces
  3. * Description: this module implement the list support used in
  4. * various place in the library.
  5. *
  6. * Copy: See Copyright for the status of this software.
  7. *
  8. * Author: Gary Pennington <Gary.Pennington@uk.sun.com>
  9. */
  10. #ifndef __XML_LINK_INCLUDE__
  11. #define __XML_LINK_INCLUDE__
  12. #include <libxml/xmlversion.h>
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. typedef struct _xmlLink xmlLink;
  17. typedef xmlLink *xmlLinkPtr;
  18. typedef struct _xmlList xmlList;
  19. typedef xmlList *xmlListPtr;
  20. /**
  21. * xmlListDeallocator:
  22. * @lk: the data to deallocate
  23. *
  24. * Callback function used to free data from a list.
  25. */
  26. typedef void (*xmlListDeallocator) (xmlLinkPtr lk);
  27. /**
  28. * xmlListDataCompare:
  29. * @data0: the first data
  30. * @data1: the second data
  31. *
  32. * Callback function used to compare 2 data.
  33. *
  34. * Returns 0 is equality, -1 or 1 otherwise depending on the ordering.
  35. */
  36. typedef int (*xmlListDataCompare) (const void *data0, const void *data1);
  37. /**
  38. * xmlListWalker:
  39. * @data: the data found in the list
  40. * @user: extra user provided data to the walker
  41. *
  42. * Callback function used when walking a list with xmlListWalk().
  43. *
  44. * Returns 0 to stop walking the list, 1 otherwise.
  45. */
  46. typedef int (*xmlListWalker) (const void *data, const void *user);
  47. /* Creation/Deletion */
  48. XMLPUBFUN xmlListPtr XMLCALL
  49. xmlListCreate (xmlListDeallocator deallocator,
  50. xmlListDataCompare compare);
  51. XMLPUBFUN void XMLCALL
  52. xmlListDelete (xmlListPtr l);
  53. /* Basic Operators */
  54. XMLPUBFUN void * XMLCALL
  55. xmlListSearch (xmlListPtr l,
  56. void *data);
  57. XMLPUBFUN void * XMLCALL
  58. xmlListReverseSearch (xmlListPtr l,
  59. void *data);
  60. XMLPUBFUN int XMLCALL
  61. xmlListInsert (xmlListPtr l,
  62. void *data) ;
  63. XMLPUBFUN int XMLCALL
  64. xmlListAppend (xmlListPtr l,
  65. void *data) ;
  66. XMLPUBFUN int XMLCALL
  67. xmlListRemoveFirst (xmlListPtr l,
  68. void *data);
  69. XMLPUBFUN int XMLCALL
  70. xmlListRemoveLast (xmlListPtr l,
  71. void *data);
  72. XMLPUBFUN int XMLCALL
  73. xmlListRemoveAll (xmlListPtr l,
  74. void *data);
  75. XMLPUBFUN void XMLCALL
  76. xmlListClear (xmlListPtr l);
  77. XMLPUBFUN int XMLCALL
  78. xmlListEmpty (xmlListPtr l);
  79. XMLPUBFUN xmlLinkPtr XMLCALL
  80. xmlListFront (xmlListPtr l);
  81. XMLPUBFUN xmlLinkPtr XMLCALL
  82. xmlListEnd (xmlListPtr l);
  83. XMLPUBFUN int XMLCALL
  84. xmlListSize (xmlListPtr l);
  85. XMLPUBFUN void XMLCALL
  86. xmlListPopFront (xmlListPtr l);
  87. XMLPUBFUN void XMLCALL
  88. xmlListPopBack (xmlListPtr l);
  89. XMLPUBFUN int XMLCALL
  90. xmlListPushFront (xmlListPtr l,
  91. void *data);
  92. XMLPUBFUN int XMLCALL
  93. xmlListPushBack (xmlListPtr l,
  94. void *data);
  95. /* Advanced Operators */
  96. XMLPUBFUN void XMLCALL
  97. xmlListReverse (xmlListPtr l);
  98. XMLPUBFUN void XMLCALL
  99. xmlListSort (xmlListPtr l);
  100. XMLPUBFUN void XMLCALL
  101. xmlListWalk (xmlListPtr l,
  102. xmlListWalker walker,
  103. const void *user);
  104. XMLPUBFUN void XMLCALL
  105. xmlListReverseWalk (xmlListPtr l,
  106. xmlListWalker walker,
  107. const void *user);
  108. XMLPUBFUN void XMLCALL
  109. xmlListMerge (xmlListPtr l1,
  110. xmlListPtr l2);
  111. XMLPUBFUN xmlListPtr XMLCALL
  112. xmlListDup (const xmlListPtr old);
  113. XMLPUBFUN int XMLCALL
  114. xmlListCopy (xmlListPtr cur,
  115. const xmlListPtr old);
  116. /* Link operators */
  117. XMLPUBFUN void * XMLCALL
  118. xmlLinkGetData (xmlLinkPtr lk);
  119. /* xmlListUnique() */
  120. /* xmlListSwap */
  121. #ifdef __cplusplus
  122. }
  123. #endif
  124. #endif /* __XML_LINK_INCLUDE__ */