C Standard Library Extensions 1.2.6
cxslist.h
1/*
2 * This file is part of the ESO C Extension Library
3 * Copyright (C) 2001-2017 European Southern Observatory
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#ifndef CX_SLIST_H
21#define CX_SLIST_H
22
23#include <cxmemory.h>
24
25CX_BEGIN_DECLS
26
27typedef struct _cx_slnode_ *cx_slist_iterator;
28typedef const struct _cx_slnode_ *cx_slist_const_iterator;
29
30typedef struct _cx_slist_ cx_slist;
31
32
33/*
34 * Create, copy and destroy operations
35 */
36
37cx_slist *cx_slist_new(void);
38void cx_slist_delete(cx_slist *);
39void cx_slist_destroy(cx_slist *, cx_free_func);
40
41/*
42 * Nonmodifying operations
43 */
44
45cxsize cx_slist_size(const cx_slist *);
46cxbool cx_slist_empty(const cx_slist *);
47cxsize cx_slist_max_size(const cx_slist *);
48
49/*
50 * Assignment operations
51 */
52
53void cx_slist_swap(cx_slist *, cx_slist *);
54cxptr cx_slist_assign(cx_slist *, cx_slist_iterator, cxcptr);
55
56/*
57 * Element access
58 */
59
60cxptr cx_slist_front(const cx_slist *);
61cxptr cx_slist_back(const cx_slist *);
62cxptr cx_slist_get(const cx_slist *, cx_slist_const_iterator);
63
64/*
65 * Iterator functions
66 */
67
68cx_slist_iterator cx_slist_begin(const cx_slist *);
69cx_slist_iterator cx_slist_end(const cx_slist *);
70cx_slist_iterator cx_slist_next(const cx_slist *, cx_slist_const_iterator);
71
72/*
73 * Inserting and removing elements
74 */
75
76void cx_slist_push_front(cx_slist *, cxcptr);
77cxptr cx_slist_pop_front(cx_slist *);
78void cx_slist_push_back(cx_slist *, cxcptr);
79cxptr cx_slist_pop_back(cx_slist *);
80
81cx_slist_iterator cx_slist_insert(cx_slist *, cx_slist_iterator, cxcptr);
82cx_slist_iterator cx_slist_erase(cx_slist *, cx_slist_iterator, cx_free_func);
83cxptr cx_slist_extract(cx_slist *, cx_slist_iterator);
84void cx_slist_remove(cx_slist *, cxcptr);
85void cx_slist_clear(cx_slist *);
86
87/*
88 * Splice functions
89 */
90
91void cx_slist_unique(cx_slist *, cx_compare_func);
92void cx_slist_splice(cx_slist *, cx_slist_iterator, cx_slist *,
93 cx_slist_iterator, cx_slist_iterator);
94void cx_slist_merge(cx_slist *, cx_slist *, cx_compare_func);
95void cx_slist_sort(cx_slist *, cx_compare_func);
96void cx_slist_reverse(cx_slist *);
97
98CX_END_DECLS
99
100#endif /* CX_SLIST_H */
cxptr cx_slist_extract(cx_slist *, cx_slist_iterator)
Extract a list element.
Definition cxslist.c:1125
void cx_slist_destroy(cx_slist *, cx_free_func)
Destroy a list and all its elements.
Definition cxslist.c:762
void cx_slist_clear(cx_slist *)
Remove all elements from a list.
Definition cxslist.c:660
void cx_slist_unique(cx_slist *, cx_compare_func)
Remove duplicates of consecutive elements.
Definition cxslist.c:1247
cxptr cx_slist_assign(cx_slist *, cx_slist_iterator, cxcptr)
Assign data to a list position.
Definition cxslist.c:879
void cx_slist_remove(cx_slist *, cxcptr)
Remove all elements with a given value from a list.
Definition cxslist.c:1207
cx_slist_iterator cx_slist_next(const cx_slist *, cx_slist_const_iterator)
Get a list iterator to the next list element.
Definition cxslist.c:632
cxptr cx_slist_pop_front(cx_slist *)
Remove the first list element.
Definition cxslist.c:1150
cx_slist_iterator cx_slist_begin(const cx_slist *)
Get list iterator to the beginning of a list.
Definition cxslist.c:580
cxptr cx_slist_get(const cx_slist *, cx_slist_const_iterator)
Get the data at a given iterator position.
Definition cxslist.c:962
cx_slist_iterator cx_slist_end(const cx_slist *)
Get a list iterator to the end of a list.
Definition cxslist.c:604
void cx_slist_splice(cx_slist *, cx_slist_iterator, cx_slist *, cx_slist_iterator, cx_slist_iterator)
Move a range of list elements in front of a given position.
Definition cxslist.c:1295
cxptr cx_slist_front(const cx_slist *)
Get the first element of a list.
Definition cxslist.c:910
cxbool cx_slist_empty(const cx_slist *)
Check whether a list is empty.
Definition cxslist.c:689
void cx_slist_push_back(cx_slist *, cxcptr)
Append data at the end of a list.
Definition cxslist.c:1059
void cx_slist_sort(cx_slist *, cx_compare_func)
Sort all elements of a list using the given comparison function.
Definition cxslist.c:1389
void cx_slist_swap(cx_slist *, cx_slist *)
Swap the data of two lists.
Definition cxslist.c:850
void cx_slist_delete(cx_slist *)
Destroy a list.
Definition cxslist.c:734
cxsize cx_slist_size(const cx_slist *)
Get the actual number of list elements.
Definition cxslist.c:803
cxptr cx_slist_pop_back(cx_slist *)
Remove the last element of a list.
Definition cxslist.c:1179
cxptr cx_slist_back(const cx_slist *)
Get the last element of a list.
Definition cxslist.c:934
void cx_slist_merge(cx_slist *, cx_slist *, cx_compare_func)
Merge two sorted lists.
Definition cxslist.c:1358
void cx_slist_reverse(cx_slist *)
Reverse the order of all list elements.
Definition cxslist.c:1413
cxsize cx_slist_max_size(const cx_slist *)
Get the maximum number of list elements possible.
Definition cxslist.c:825
cx_slist_iterator cx_slist_erase(cx_slist *, cx_slist_iterator, cx_free_func)
Erase a list list element.
Definition cxslist.c:1091
cx_slist * cx_slist_new(void)
Create a new list without any elements.
Definition cxslist.c:710
cx_slist_iterator cx_slist_insert(cx_slist *, cx_slist_iterator, cxcptr)
Insert data into a list at a given iterator position.
Definition cxslist.c:990
void cx_slist_push_front(cx_slist *, cxcptr)
Insert data at the beginning of a list.
Definition cxslist.c:1029