xine-lib  1.2.9
list.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2000-2009 the xine project
3  *
4  * This file is part of xine, a free video player.
5  *
6  * xine is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * xine is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
19  *
20  * Doubly-linked linked list.
21  *
22  * Exemples:
23  *
24  * Create a list:
25  * xine_list_t *list = xine_list_new();
26  *
27  * Delete a list:
28  * xine_list_delete(list);
29  *
30  * Walk thru a list:
31  * xine_list_iterator_t ite = xine_list_front(list);
32  * while (ite) {
33  * _useful code here_
34  * ite = xine_list_next(list, ite);
35  * }
36  *
37  * The list elements are managed using memory chunks and a free list. The first
38  * chunk contains 32 elements, each following chunk is two time as big as the
39  * previous one, with a limit of 64K elements.
40  */
41 #ifndef XINE_LIST_H
42 #define XINE_LIST_H
43 
44 #include <xine/attributes.h>
45 
46 /* Doubly-linked list type */
47 typedef struct xine_list_s xine_list_t;
48 
49 /* List iterator */
50 typedef void* xine_list_iterator_t;
51 
52 /* Constructor */
54 
55 /* Destructor */
57 
58 /* Returns the number of element stored in the list */
59 unsigned int xine_list_size(xine_list_t *list) XINE_PROTECTED;
60 
61 /* Returns true if the number of elements is zero, false otherwise */
62 unsigned int xine_list_empty(xine_list_t *list) XINE_PROTECTED;
63 
64 /* Adds the element at the beginning of the list */
65 void xine_list_push_front(xine_list_t *list, void *value) XINE_PROTECTED;
66 
67 /* Adds the element at the end of the list */
68 void xine_list_push_back(xine_list_t *list, void *value) XINE_PROTECTED;
69 
70 /* Remove all elements from a list */
72 
73 /* Insert the element elem into the list at the position specified by the
74  iterator (before the element, if any, that was previously at the iterator's
75  position). The return value is an iterator that specifies the position of
76  the inserted element. */
78  xine_list_iterator_t position,
79  void *value) XINE_PROTECTED;
80 
81 /* Remove one element from a list.*/
83 
84 /* Returns an iterator that references the first element of the list */
86 
87 /* Returns an iterator that references the last element of the list */
89 
90 /* Perform a linear search of a given value, and returns an iterator that
91  references this value or NULL if not found */
93 
94 /* Increments the iterator's value, so it specifies the next element in the list
95  or NULL at the end of the list */
97 
98 /* Increments the iterator's value, so it specifies the previous element in the list
99  or NULL at the beginning of the list */
101 
102 /* Returns the value at the position specified by the iterator */
104 
105 #endif
106 
unsigned int xine_list_size(xine_list_t *list)
Definition: list.c:184
#define XINE_MALLOC
Definition: attributes.h:119
xine_list_iterator_t xine_list_back(xine_list_t *list)
Definition: list.c:196
void xine_list_push_back(xine_list_t *list, void *value)
Definition: list.c:200
xine_list_iterator_t xine_list_insert(xine_list_t *list, xine_list_iterator_t position, void *value)
Definition: list.c:299
void xine_list_remove(xine_list_t *list, xine_list_iterator_t position)
Definition: list.c:277
void xine_list_push_front(xine_list_t *list, void *value)
Definition: list.c:220
xine_list_iterator_t xine_list_find(xine_list_t *list, void *value)
Definition: list.c:335
xine_list_iterator_t xine_list_next(xine_list_t *list, xine_list_iterator_t ite)
Definition: list.c:253
void * xine_list_iterator_t
Definition: list.h:50
Definition: list.c:51
xine_list_iterator_t xine_list_prev(xine_list_t *list, xine_list_iterator_t ite)
Definition: list.c:262
#define XINE_PROTECTED
Definition: attributes.h:73
xine_list_iterator_t xine_list_front(xine_list_t *list)
Definition: list.c:192
void * xine_list_get_value(xine_list_t *list, xine_list_iterator_t ite)
Definition: list.c:271
void xine_list_clear(xine_list_t *list)
Definition: list.c:240
unsigned int xine_list_empty(xine_list_t *list)
Definition: list.c:188
xine_list_t * xine_list_new(void)
Definition: list.c:146
void xine_list_delete(xine_list_t *list)
Definition: list.c:171