xine-lib  1.2.10
list.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2000-2019 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 */
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 */
66 
67 /* Adds the element at the end of the list */
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 /* If iterator == NULL: same as xine_list_front ().
95  Otherwise, increments the iterator's value, so it specifies the next element in the list,
96  or NULL at the end of the list. */
98 
99 /* Like xine_list_next () but returns the user value or NULL. */
101 
102 /* If iterator == NULL: same as xine_list_back ().
103  Otherwise, decrements the iterator's value, so it specifies the previous element in the list,
104  or NULL at the beginning of the list */
106 
107 /* Like xine_list_prev () but returns the user value or NULL. */
109 
110 /* Returns the value at the position specified by the iterator */
112 
113 #endif
114 
xine_list_iterator_t
struct xine_list_elem_s * xine_list_iterator_t
Definition: list.h:50
XINE_MALLOC
#define XINE_MALLOC
Definition: attributes.h:139
xine_list_remove
void xine_list_remove(xine_list_t *list, xine_list_iterator_t position)
Definition: list.c:246
xine_list_empty
unsigned int xine_list_empty(xine_list_t *list)
Definition: list.c:150
xine_list_elem_s::value
void * value
Definition: list.c:40
xine_list_get_value
void * xine_list_get_value(xine_list_t *list, xine_list_iterator_t ite)
Definition: list.c:240
attributes.h
xine_list_push_back
void xine_list_push_back(xine_list_t *list, void *value)
Definition: list.c:162
xine_list_push_front
void xine_list_push_front(xine_list_t *list, void *value)
Definition: list.c:176
xine_list_back
xine_list_iterator_t xine_list_back(xine_list_t *list)
Definition: list.c:158
xine_list_front
xine_list_iterator_t xine_list_front(xine_list_t *list)
Definition: list.c:154
xine_list_insert
xine_list_iterator_t xine_list_insert(xine_list_t *list, xine_list_iterator_t position, void *value)
Definition: list.c:256
xine_list_s
Definition: list.c:51
xine_list_clear
void xine_list_clear(xine_list_t *list)
Definition: list.c:103
xine_list_next_value
void * xine_list_next_value(xine_list_t *list, xine_list_iterator_t *ite)
Definition: list.c:197
xine_list_new
xine_list_t * xine_list_new(void)
Definition: list.c:72
xine_list_delete
void xine_list_delete(xine_list_t *list)
Definition: list.c:108
xine_list_find
xine_list_iterator_t xine_list_find(xine_list_t *list, void *value)
Definition: list.c:275
xine_list_size
unsigned int xine_list_size(xine_list_t *list)
Definition: list.c:146
xine_list_prev_value
void * xine_list_prev_value(xine_list_t *list, xine_list_iterator_t *ite)
Definition: list.c:222
XINE_PROTECTED
#define XINE_PROTECTED
Definition: attributes.h:73
xine_list_prev
xine_list_iterator_t xine_list_prev(xine_list_t *list, xine_list_iterator_t ite)
Definition: list.c:215
xine_list_next
xine_list_iterator_t xine_list_next(xine_list_t *list, xine_list_iterator_t ite)
Definition: list.c:190
xine_list_elem_s
Definition: list.c:37