plibsys 0.0.5
plist.h
Go to the documentation of this file.
1/*
2 * The MIT License
3 *
4 * Copyright (C) 2010-2023 Alexander Saprykin <saprykin.spb@gmail.com>
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 * 'Software'), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sublicense, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be
15 * included in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 */
25
80#if !defined (PLIBSYS_H_INSIDE) && !defined (PLIBSYS_COMPILATION)
81# error "Header files shouldn't be included directly, consider using <plibsys.h> instead."
82#endif
83
84#ifndef PLIBSYS_HEADER_PLIST_H
85#define PLIBSYS_HEADER_PLIST_H
86
87#include <pmacros.h>
88#include <ptypes.h>
89
91
93typedef struct PList_ PList;
94
100
113
127
144 PFunc func,
145 ppointer user_data);
146
157
165
175
188
196
198
199#endif /* PLIBSYS_HEADER_PLIST_H */
P_LIB_API void p_list_foreach(PList *list, PFunc func, ppointer user_data)
Calls a specified function for each list node.
P_LIB_API psize p_list_length(const PList *list)
Gets the number of list nodes.
P_LIB_API PList * p_list_last(PList *list)
Gets the last node from the list.
P_LIB_API PList * p_list_reverse(PList *list) P_GNUC_WARN_UNUSED_RESULT
Reverses the list order.
P_LIB_API PList * p_list_prepend(PList *list, ppointer data) P_GNUC_WARN_UNUSED_RESULT
Prepends data to a list.
P_LIB_API void p_list_free(PList *list)
Frees list memory.
P_LIB_API PList * p_list_remove(PList *list, pconstpointer data) P_GNUC_WARN_UNUSED_RESULT
Removes data from a list.
P_LIB_API PList * p_list_append(PList *list, ppointer data) P_GNUC_WARN_UNUSED_RESULT
Appends data to a list.
Miscellaneous macros.
#define P_GNUC_WARN_UNUSED_RESULT
Gives a warning if the result returned from a function is not being used.
Definition pmacros.h:72
#define P_BEGIN_DECLS
Starts .h file declarations to be exported as C functions.
Definition pmacros.h:298
#define P_END_DECLS
Closes .h file declarations to be exported as C functions, should be always used after P_BEGIN_DECLS.
Definition pmacros.h:299
#define P_LIB_API
Exports a symbol from a shared library.
Definition pmacros.h:138
Types definitions.
void(* PFunc)(ppointer data, ppointer user_data)
General purpose function.
Definition ptypes.h:1090
unsigned int psize
Type for a platform independent size_t.
Definition ptypes.h:224
const void * pconstpointer
Type for a const pointer.
Definition ptypes.h:111
void * ppointer
Type for a pointer.
Definition ptypes.h:109
Node for a singly linked list.
Definition plist.h:96
PList * next
Next list node.
Definition plist.h:98
ppointer data
Pointer to the node data.
Definition plist.h:97