xine-lib: xine-lib-1.2.13/include/xine/list.h Source File

xine-lib 1.2.13-20230125hg15249

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 */
50 typedef struct xine_list_elem_s *xine_list_iterator_t;
51
52/* Constructor */
53 xine_list_t *xine_list_new(void) XINE_MALLOC XINE_PROTECTED;
54
55/* Destructor */
56void xine_list_delete(xine_list_t *list) XINE_PROTECTED;
57
58/* Returns the number of element stored in the list */
59unsigned int xine_list_size(xine_list_t *list) XINE_PROTECTED;
60
61/* Returns true if the number of elements is zero, false otherwise */
62unsigned int xine_list_empty(xine_list_t *list) XINE_PROTECTED;
63
64/* Adds the element at the beginning of the list */
65void xine_list_push_front(xine_list_t *list, void *value) XINE_PROTECTED;
66
67/* Adds the element at the end of the list */
68void xine_list_push_back(xine_list_t *list, void *value) XINE_PROTECTED;
69
70/* Remove all elements from a list */
71void xine_list_clear(xine_list_t *list) XINE_PROTECTED;
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. */
77 xine_list_iterator_t xine_list_insert(xine_list_t *list,
78 xine_list_iterator_t position,
79 void *value) XINE_PROTECTED;
80
81/* Remove one element from a list.*/
82void xine_list_remove(xine_list_t *list, xine_list_iterator_t position) XINE_PROTECTED;
83
84/* Returns an iterator that references the first element of the list */
85 xine_list_iterator_t xine_list_front(xine_list_t *list) XINE_PROTECTED;
86
87/* Returns an iterator that references the last element of the list */
88 xine_list_iterator_t xine_list_back(xine_list_t *list) XINE_PROTECTED;
89
90/* Perform a linear search of a given value, and returns an iterator that
91 references this value or NULL if not found */
92 xine_list_iterator_t xine_list_find(xine_list_t *list, void *value) XINE_PROTECTED;
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. */
97 xine_list_iterator_t xine_list_next(xine_list_t *list, xine_list_iterator_t ite) XINE_PROTECTED;
98
99/* Like xine_list_next () but returns the user value or NULL. */
100void *xine_list_next_value (xine_list_t *list, xine_list_iterator_t *ite) XINE_PROTECTED;
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 */
105 xine_list_iterator_t xine_list_prev(xine_list_t *list, xine_list_iterator_t ite) XINE_PROTECTED;
106
107/* Like xine_list_prev () but returns the user value or NULL. */
108void *xine_list_prev_value (xine_list_t *list, xine_list_iterator_t *ite) XINE_PROTECTED;
109
110/* Returns the value at the position specified by the iterator */
111void *xine_list_get_value(xine_list_t *list, xine_list_iterator_t ite) XINE_PROTECTED;
112
113#endif
114
attributes.h
XINE_MALLOC
#define XINE_MALLOC
Definition attributes.h:141
XINE_PROTECTED
#define XINE_PROTECTED
Definition attributes.h:75
xine_list_clear
void xine_list_clear(xine_list_t *list)
Definition list.c:103
xine_list_empty
unsigned int xine_list_empty(xine_list_t *list)
Definition list.c:150
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_prev_value
void * xine_list_prev_value(xine_list_t *list, xine_list_iterator_t *ite)
Definition list.c:222
xine_list_back
xine_list_iterator_t xine_list_back(xine_list_t *list)
Definition list.c:158
xine_list_iterator_t
struct xine_list_elem_s * xine_list_iterator_t
Definition list.h:50
xine_list_push_back
void xine_list_push_back(xine_list_t *list, void *value)
Definition list.c:162
xine_list_front
xine_list_iterator_t xine_list_front(xine_list_t *list)
Definition list.c:154
xine_list_get_value
void * xine_list_get_value(xine_list_t *list, xine_list_iterator_t ite)
Definition list.c:240
xine_list_remove
void xine_list_remove(xine_list_t *list, xine_list_iterator_t position)
Definition list.c:246
xine_list_push_front
void xine_list_push_front(xine_list_t *list, void *value)
Definition list.c:176
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_prev
xine_list_iterator_t xine_list_prev(xine_list_t *list, xine_list_iterator_t ite)
Definition list.c:215
xine_list_find
xine_list_iterator_t xine_list_find(xine_list_t *list, void *value)
Definition list.c:275
xine_list_delete
void xine_list_delete(xine_list_t *list)
Definition list.c:108
xine_list_size
unsigned int xine_list_size(xine_list_t *list)
Definition list.c:146
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_elem_s
Definition list.c:37
xine_list_elem_s::value
void * value
Definition list.c:40
xine_list_s
Definition list.c:51