2 * GPAC - Multimedia Framework C SDK
\r
4 * Copyright (c) Jean Le Feuvre 2000-2005
\r
5 * All rights reserved
\r
7 * This file is part of GPAC / common tools sub-project
\r
9 * GPAC is free software; you can redistribute it and/or modify
\r
10 * it under the terms of the GNU Lesser General Public License as published by
\r
11 * the Free Software Foundation; either version 2, or (at your option)
\r
12 * any later version.
\r
14 * GPAC is distributed in the hope that it will be useful,
\r
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
17 * GNU Lesser General Public License for more details.
\r
19 * You should have received a copy of the GNU Lesser General Public
\r
20 * License along with this library; see the file COPYING. If not, write to
\r
21 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
\r
33 * \file <gpac/list.h>
\r
34 * \brief list functions.
\r
38 * \addtogroup list_grp list
\r
39 * \ingroup utils_grp
\r
40 * \brief List object
\r
42 * This section documents the list object of the GPAC framework.
\r
46 #include <gpac/tools.h>
\r
48 typedef struct _tag_array GF_List;
\r
51 * \brief list constructor
\r
53 * Constructs a new list object
\r
54 * \return new list object
\r
56 GF_List *gf_list_new();
\r
58 * \brief list destructor
\r
60 * Destructs a list object
\r
61 * \param ptr list object to destruct
\r
62 * \note It is the caller responsability to destroy the content of the list if needed
\r
64 void gf_list_del(GF_List *ptr);
\r
68 * Returns number of items in the list
\r
69 * \param ptr target list object
\r
70 * \return number of items in the list
\r
72 u32 gf_list_count(GF_List *ptr);
\r
76 * Adds an item at the end of the list
\r
77 * \param ptr target list object
\r
78 * \param item item to add
\r
80 GF_Err gf_list_add(GF_List *ptr, void* item);
\r
82 * \brief inserts item
\r
84 * Insert an item in the list
\r
85 * \param ptr target list object
\r
86 * \param item item to add
\r
87 * \param position insertion position. It is expressed between 0 and gf_list_count-1, and any bigger value is equivalent to gf_list_add
\r
89 GF_Err gf_list_insert(GF_List *ptr, void *item, u32 position);
\r
91 * \brief removes item
\r
93 * Removes an item from the list given its position
\r
94 * \param ptr target list object
\r
95 * \param position position of the item to remove. It is expressed between 0 and gf_list_count-1.
\r
96 * \note It is the caller responsability to destroy the content of the list if needed
\r
98 GF_Err gf_list_rem(GF_List *ptr, u32 position);
\r
102 * Gets an item from the list given its position
\r
103 * \param ptr target list object
\r
104 * \param position position of the item to get. It is expressed between 0 and gf_list_count-1.
\r
106 void *gf_list_get(GF_List *ptr, u32 position);
\r
108 * \brief finds item
\r
110 * Finds an item in the list
\r
111 * \param ptr target list object.
\r
112 * \param item the item to find.
\r
113 * \return 0-based item position in the list, or -1 if the item could not be found.
\r
115 s32 gf_list_find(GF_List *ptr, void *item);
\r
117 * \brief deletes item
\r
119 * Deletes an item from the list
\r
120 * \param ptr target list object.
\r
121 * \param item the item to find.
\r
122 * \return 0-based item position in the list before removal, or -1 if the item could not be found.
\r
124 s32 gf_list_del_item(GF_List *ptr, void *item);
\r
126 * \brief resets list
\r
128 * Resets the content of the list
\r
129 * \param ptr target list object.
\r
130 * \note It is the caller responsability to destroy the content of the list if needed
\r
132 void gf_list_reset(GF_List *ptr);
\r
134 * \brief gets last item
\r
136 * Gets last item o fthe list
\r
137 * \param ptr target list object
\r
139 void *gf_list_last(GF_List *ptr);
\r
141 * \brief removes last item
\r
143 * Removes the last item of the list
\r
144 * \param ptr target list object
\r
145 * \note It is the caller responsability to destroy the content of the list if needed
\r
147 GF_Err gf_list_rem_last(GF_List *ptr);
\r
151 * \brief list enumerator
\r
153 * Retrieves given list item and increment current position
\r
154 * \param ptr target list object
\r
155 * \param pos target item position. The position is automatically incremented regardless of the return value
\r
156 * \note A typical enumeration will start with a value of 0 until NULL is returned.
\r
158 void *gf_list_enum(GF_List *ptr, u32 *pos);
\r
167 #endif /*_GF_LIST_H_*/
\r