PageRenderTime 39ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/GPAC/list.h

https://github.com/upyzl/direct264umod
C Header | 168 lines | 24 code | 14 blank | 130 comment | 0 complexity | 80841ecb998d044cd5784353aa132dba MD5 | raw file
Possible License(s): GPL-2.0
  1. /*
  2. * GPAC - Multimedia Framework C SDK
  3. *
  4. * Copyright (c) Jean Le Feuvre 2000-2005
  5. * All rights reserved
  6. *
  7. * This file is part of GPAC / common tools sub-project
  8. *
  9. * GPAC is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU Lesser General Public License as published by
  11. * the Free Software Foundation; either version 2, or (at your option)
  12. * any later version.
  13. *
  14. * GPAC is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; see the file COPYING. If not, write to
  21. * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  22. *
  23. */
  24. #ifndef _GF_LIST_H_
  25. #define _GF_LIST_H_
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. /*!
  30. * \file <gpac/list.h>
  31. * \brief list functions.
  32. */
  33. /*!
  34. * \addtogroup list_grp list
  35. * \ingroup utils_grp
  36. * \brief List object
  37. *
  38. * This section documents the list object of the GPAC framework.
  39. * @{
  40. */
  41. #include <gpac/tools.h>
  42. typedef struct _tag_array GF_List;
  43. /*!
  44. * \brief list constructor
  45. *
  46. * Constructs a new list object
  47. * \return new list object
  48. */
  49. GF_List *gf_list_new();
  50. /*!
  51. * \brief list destructor
  52. *
  53. * Destructs a list object
  54. * \param ptr list object to destruct
  55. * \note It is the caller responsability to destroy the content of the list if needed
  56. */
  57. void gf_list_del(GF_List *ptr);
  58. /*!
  59. * \brief get count
  60. *
  61. * Returns number of items in the list
  62. * \param ptr target list object
  63. * \return number of items in the list
  64. */
  65. u32 gf_list_count(GF_List *ptr);
  66. /*!
  67. * \brief add item
  68. *
  69. * Adds an item at the end of the list
  70. * \param ptr target list object
  71. * \param item item to add
  72. */
  73. GF_Err gf_list_add(GF_List *ptr, void* item);
  74. /*!
  75. * \brief inserts item
  76. *
  77. * Insert an item in the list
  78. * \param ptr target list object
  79. * \param item item to add
  80. * \param position insertion position. It is expressed between 0 and gf_list_count-1, and any bigger value is equivalent to gf_list_add
  81. */
  82. GF_Err gf_list_insert(GF_List *ptr, void *item, u32 position);
  83. /*!
  84. * \brief removes item
  85. *
  86. * Removes an item from the list given its position
  87. * \param ptr target list object
  88. * \param position position of the item to remove. It is expressed between 0 and gf_list_count-1.
  89. * \note It is the caller responsability to destroy the content of the list if needed
  90. */
  91. GF_Err gf_list_rem(GF_List *ptr, u32 position);
  92. /*!
  93. * \brief gets item
  94. *
  95. * Gets an item from the list given its position
  96. * \param ptr target list object
  97. * \param position position of the item to get. It is expressed between 0 and gf_list_count-1.
  98. */
  99. void *gf_list_get(GF_List *ptr, u32 position);
  100. /*!
  101. * \brief finds item
  102. *
  103. * Finds an item in the list
  104. * \param ptr target list object.
  105. * \param item the item to find.
  106. * \return 0-based item position in the list, or -1 if the item could not be found.
  107. */
  108. s32 gf_list_find(GF_List *ptr, void *item);
  109. /*!
  110. * \brief deletes item
  111. *
  112. * Deletes an item from the list
  113. * \param ptr target list object.
  114. * \param item the item to find.
  115. * \return 0-based item position in the list before removal, or -1 if the item could not be found.
  116. */
  117. s32 gf_list_del_item(GF_List *ptr, void *item);
  118. /*!
  119. * \brief resets list
  120. *
  121. * Resets the content of the list
  122. * \param ptr target list object.
  123. * \note It is the caller responsability to destroy the content of the list if needed
  124. */
  125. void gf_list_reset(GF_List *ptr);
  126. /*!
  127. * \brief gets last item
  128. *
  129. * Gets last item o fthe list
  130. * \param ptr target list object
  131. */
  132. void *gf_list_last(GF_List *ptr);
  133. /*!
  134. * \brief removes last item
  135. *
  136. * Removes the last item of the list
  137. * \param ptr target list object
  138. * \note It is the caller responsability to destroy the content of the list if needed
  139. */
  140. GF_Err gf_list_rem_last(GF_List *ptr);
  141. /*!
  142. * \brief list enumerator
  143. *
  144. * Retrieves given list item and increment current position
  145. * \param ptr target list object
  146. * \param pos target item position. The position is automatically incremented regardless of the return value
  147. * \note A typical enumeration will start with a value of 0 until NULL is returned.
  148. */
  149. void *gf_list_enum(GF_List *ptr, u32 *pos);
  150. /*! @} */
  151. #ifdef __cplusplus
  152. }
  153. #endif
  154. #endif /*_GF_LIST_H_*/