cxslist.h
/*
* This file is part of the ESO C Extension Library
* Copyright (C) 2001-2026 European Southern Observatory
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <https://www.gnu.org/licenses/>.
*/
#ifndef CX_SLIST_H
#define CX_SLIST_H
#include "cxtypes.h"
CX_BEGIN_DECLS
typedef struct _cx_slnode_ *cx_slist_iterator;
typedef const struct _cx_slnode_ *cx_slist_const_iterator;
typedef struct _cx_slist_ cx_slist;
/*
* Create, copy and destroy operations
*/
cx_slist *cx_slist_new(void);
void cx_slist_delete(cx_slist *);
void cx_slist_destroy(cx_slist *, cx_free_func);
/*
* Nonmodifying operations
*/
cxsize cx_slist_size(const cx_slist *);
cxbool cx_slist_empty(const cx_slist *);
cxsize cx_slist_max_size(const cx_slist *);
/*
* Assignment operations
*/
void cx_slist_swap(cx_slist *, cx_slist *);
cxptr cx_slist_assign(cx_slist *, cx_slist_iterator, cxcptr);
/*
* Element access
*/
cxptr cx_slist_front(const cx_slist *);
cxptr cx_slist_back(const cx_slist *);
cxptr cx_slist_get(const cx_slist *, cx_slist_const_iterator);
/*
* Iterator functions
*/
cx_slist_iterator cx_slist_begin(const cx_slist *);
cx_slist_iterator cx_slist_end(const cx_slist *);
cx_slist_iterator cx_slist_next(const cx_slist *, cx_slist_const_iterator);
/*
* Inserting and removing elements
*/
void cx_slist_push_front(cx_slist *, cxcptr);
cxptr cx_slist_pop_front(cx_slist *);
void cx_slist_push_back(cx_slist *, cxcptr);
cxptr cx_slist_pop_back(cx_slist *);
cx_slist_iterator cx_slist_insert(cx_slist *, cx_slist_iterator, cxcptr);
cx_slist_iterator cx_slist_erase(cx_slist *, cx_slist_iterator, cx_free_func);
cxptr cx_slist_extract(cx_slist *, cx_slist_iterator);
void cx_slist_remove(cx_slist *, cxcptr);
void cx_slist_clear(cx_slist *);
/*
* Splice functions
*/
void cx_slist_unique(cx_slist *, cx_compare_func);
void cx_slist_splice(cx_slist *, cx_slist_iterator, cx_slist *,
cx_slist_iterator, cx_slist_iterator);
void cx_slist_merge(cx_slist *, cx_slist *, cx_compare_func);
void cx_slist_sort(cx_slist *, cx_compare_func);
void cx_slist_reverse(cx_slist *);
CX_END_DECLS
#endif /* CX_SLIST_H */
cx_slist_extract
cxptr cx_slist_extract(cx_slist *, cx_slist_iterator)
Extract a list element.
Definition cxslist.c:1058
cx_slist_destroy
void cx_slist_destroy(cx_slist *, cx_free_func)
Destroy a list and all its elements.
Definition cxslist.c:716
cx_slist_clear
void cx_slist_clear(cx_slist *)
Remove all elements from a list.
Definition cxslist.c:622
cx_slist_unique
void cx_slist_unique(cx_slist *, cx_compare_func)
Remove duplicates of consecutive elements.
Definition cxslist.c:1174
cx_slist_assign
cxptr cx_slist_assign(cx_slist *, cx_slist_iterator, cxcptr)
Assign data to a list position.
Definition cxslist.c:827
cx_slist_remove
void cx_slist_remove(cx_slist *, cxcptr)
Remove all elements with a given value from a list.
Definition cxslist.c:1134
cx_slist_next
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:596
cx_slist_pop_front
cxptr cx_slist_pop_front(cx_slist *)
Remove the first list element.
Definition cxslist.c:1081
cx_slist_begin
cx_slist_iterator cx_slist_begin(const cx_slist *)
Get list iterator to the beginning of a list.
Definition cxslist.c:548
cx_slist_get
cxptr cx_slist_get(const cx_slist *, cx_slist_const_iterator)
Get the data at a given iterator position.
Definition cxslist.c:905
cx_slist_end
cx_slist_iterator cx_slist_end(const cx_slist *)
Get a list iterator to the end of a list.
Definition cxslist.c:570
cx_slist_splice
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:1222
cx_slist_front
cxptr cx_slist_front(const cx_slist *)
Get the first element of a list.
Definition cxslist.c:856
cx_slist_empty
cxbool cx_slist_empty(const cx_slist *)
Check whether a list is empty.
Definition cxslist.c:649
cx_slist_push_back
void cx_slist_push_back(cx_slist *, cxcptr)
Append data at the end of a list.
Definition cxslist.c:996
cx_slist_sort
void cx_slist_sort(cx_slist *, cx_compare_func)
Sort all elements of a list using the given comparison function.
Definition cxslist.c:1308
cx_slist_swap
void cx_slist_swap(cx_slist *, cx_slist *)
Swap the data of two lists.
Definition cxslist.c:800
cx_slist_delete
void cx_slist_delete(cx_slist *)
Destroy a list.
Definition cxslist.c:690
cx_slist_size
cxsize cx_slist_size(const cx_slist *)
Get the actual number of list elements.
Definition cxslist.c:757
cx_slist_pop_back
cxptr cx_slist_pop_back(cx_slist *)
Remove the last element of a list.
Definition cxslist.c:1108
cx_slist_back
cxptr cx_slist_back(const cx_slist *)
Get the last element of a list.
Definition cxslist.c:878
cx_slist_merge
void cx_slist_merge(cx_slist *, cx_slist *, cx_compare_func)
Merge two sorted lists.
Definition cxslist.c:1279
cx_slist_reverse
void cx_slist_reverse(cx_slist *)
Reverse the order of all list elements.
Definition cxslist.c:1330
cx_slist_max_size
cxsize cx_slist_max_size(const cx_slist *)
Get the maximum number of list elements possible.
Definition cxslist.c:777
cx_slist_erase
cx_slist_iterator cx_slist_erase(cx_slist *, cx_slist_iterator, cx_free_func)
Erase a list list element.
Definition cxslist.c:1026
cx_slist_new
cx_slist * cx_slist_new(void)
Create a new list without any elements.
Definition cxslist.c:668
cx_slist_insert
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:931
cx_slist_push_front
void cx_slist_push_front(cx_slist *, cxcptr)
Insert data at the beginning of a list.
Definition cxslist.c:968