cxlist.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_LIST_H
#define CX_LIST_H
#include "cxtypes.h"
CX_BEGIN_DECLS
typedef struct _cx_lnode_ *cx_list_iterator;
typedef const struct _cx_lnode_ *cx_list_const_iterator;
typedef struct _cx_list_ cx_list;
/*
* Create, copy and destroy operations
*/
cx_list *cx_list_new(void);
void cx_list_delete(cx_list *);
void cx_list_destroy(cx_list *, cx_free_func);
/*
* Non-modifying operations
*/
cxsize cx_list_size(const cx_list *);
cxbool cx_list_empty(const cx_list *);
cxsize cx_list_max_size(const cx_list *);
/*
* Assignment operations
*/
void cx_list_swap(cx_list *, cx_list *);
cxptr cx_list_assign(cx_list *, cx_list_iterator, cxcptr);
/*
* Element access
*/
cxptr cx_list_front(const cx_list *);
cxptr cx_list_back(const cx_list *);
cxptr cx_list_get(const cx_list *, cx_list_const_iterator);
/*
* Iterator functions
*/
cx_list_iterator cx_list_begin(const cx_list *);
cx_list_iterator cx_list_end(const cx_list *);
cx_list_iterator cx_list_next(const cx_list *, cx_list_const_iterator);
cx_list_iterator cx_list_previous(const cx_list *, cx_list_const_iterator);
/*
* Inserting and removing elements
*/
void cx_list_push_front(cx_list *, cxcptr);
cxptr cx_list_pop_front(cx_list *);
void cx_list_push_back(cx_list *, cxcptr);
cxptr cx_list_pop_back(cx_list *);
cx_list_iterator cx_list_insert(cx_list *, cx_list_iterator, cxcptr);
cx_list_iterator cx_list_erase(cx_list *, cx_list_iterator, cx_free_func);
cxptr cx_list_extract(cx_list *, cx_list_iterator);
void cx_list_remove(cx_list *, cxcptr);
void cx_list_clear(cx_list *);
/*
* Splice functions
*/
void cx_list_unique(cx_list *, cx_compare_func);
void cx_list_splice(cx_list *, cx_list_iterator, cx_list *, cx_list_iterator,
cx_list_iterator);
void cx_list_merge(cx_list *, cx_list *, cx_compare_func);
void cx_list_sort(cx_list *, cx_compare_func);
void cx_list_reverse(cx_list *);
CX_END_DECLS
#endif /* CX_LIST_H */
cx_list_reverse
void cx_list_reverse(cx_list *)
Reverse the order of all list elements.
Definition cxlist.c:1340
cx_list_splice
void cx_list_splice(cx_list *, cx_list_iterator, cx_list *, cx_list_iterator, cx_list_iterator)
Move a range of list elements in front of a given position.
Definition cxlist.c:1239
cx_list_unique
void cx_list_unique(cx_list *, cx_compare_func)
Remove duplicates of consecutive elements.
Definition cxlist.c:1187
cx_list_insert
cx_list_iterator cx_list_insert(cx_list *, cx_list_iterator, cxcptr)
Insert data into a list at a given iterator position.
Definition cxlist.c:931
cx_list_sort
void cx_list_sort(cx_list *, cx_compare_func)
Sort all elements of a list using the given comparison function.
Definition cxlist.c:1318
cx_list_front
cxptr cx_list_front(const cx_list *)
Get the first element of a list.
Definition cxlist.c:856
cx_list_previous
cx_list_iterator cx_list_previous(const cx_list *, cx_list_const_iterator)
Get an iterator for the previous list element.
Definition cxlist.c:583
cx_list_new
cx_list * cx_list_new(void)
Create a new list without any elements.
Definition cxlist.c:653
cx_list_erase
cx_list_iterator cx_list_erase(cx_list *, cx_list_iterator, cx_free_func)
Erase a list element.
Definition cxlist.c:1021
cx_list_push_front
void cx_list_push_front(cx_list *, cxcptr)
Insert data at the beginning of a list.
Definition cxlist.c:968
cx_list_get
cxptr cx_list_get(const cx_list *, cx_list_const_iterator)
Get the data at a given iterator position.
Definition cxlist.c:905
cx_list_clear
void cx_list_clear(cx_list *)
Remove all elements from a list.
Definition cxlist.c:609
cx_list_begin
cx_list_iterator cx_list_begin(const cx_list *)
Get an iterator for the first list element.
Definition cxlist.c:511
cx_list_extract
cxptr cx_list_extract(cx_list *, cx_list_iterator)
Extract a list element.
Definition cxlist.c:1053
cx_list_pop_back
cxptr cx_list_pop_back(cx_list *)
Remove the last element of a list.
Definition cxlist.c:1117
cx_list_next
cx_list_iterator cx_list_next(const cx_list *, cx_list_const_iterator)
Get an iterator for the next list element.
Definition cxlist.c:557
cx_list_end
cx_list_iterator cx_list_end(const cx_list *)
Get an iterator for the position after the last list element.
Definition cxlist.c:533
cx_list_push_back
void cx_list_push_back(cx_list *, cxcptr)
Append data at the end of a list.
Definition cxlist.c:996
cx_list_merge
void cx_list_merge(cx_list *, cx_list *, cx_compare_func)
Merge two sorted lists.
Definition cxlist.c:1289
cx_list_back
cxptr cx_list_back(const cx_list *)
Get the last element of a list.
Definition cxlist.c:882
cx_list_delete
void cx_list_delete(cx_list *)
Destroy a list.
Definition cxlist.c:675
cx_list_pop_front
cxptr cx_list_pop_front(cx_list *)
Remove the first list element.
Definition cxlist.c:1087
cx_list_empty
cxbool cx_list_empty(const cx_list *)
Check whether a list is empty.
Definition cxlist.c:634
cx_list_swap
void cx_list_swap(cx_list *, cx_list *)
Swap the data of two lists.
Definition cxlist.c:783
cx_list_destroy
void cx_list_destroy(cx_list *, cx_free_func)
Destroy a list and all its elements.
Definition cxlist.c:701
cx_list_size
cxsize cx_list_size(const cx_list *)
Get the actual number of list elements.
Definition cxlist.c:740
cx_list_remove
void cx_list_remove(cx_list *, cxcptr)
Remove all elements with a given value from a list.
Definition cxlist.c:1145
cx_list_max_size
cxsize cx_list_max_size(const cx_list *)
Get the maximum number of list elements possible.
Definition cxlist.c:760
cx_list_assign
cxptr cx_list_assign(cx_list *, cx_list_iterator, cxcptr)
Assign data to a list element.
Definition cxlist.c:824