libannodex  0.7.3
anx_list.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 Commonwealth Scientific and Industrial Research
3  Organisation (CSIRO) Australia
4 
5  Redistribution and use in source and binary forms, with or without
6  modification, are permitted provided that the following conditions
7  are met:
8 
9  - Redistributions of source code must retain the above copyright
10  notice, this list of conditions and the following disclaimer.
11 
12  - Redistributions in binary form must reproduce the above copyright
13  notice, this list of conditions and the following disclaimer in the
14  documentation and/or other materials provided with the distribution.
15 
16  - Neither the name of CSIRO Australia nor the names of its
17  contributors may be used to endorse or promote products derived from
18  this software without specific prior written permission.
19 
20  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR
24  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32 
33 #ifndef __ANX_LIST_H__
34 #define __ANX_LIST_H__
35 
40 #include <annodex/anx_core.h>
41 
45 typedef struct _AnxList AnxList;
46 
47 struct _AnxList {
48  AnxList * prev;
49  AnxList * next;
50  void * data;
51 };
52 
53 
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57 
61 AnxList * anx_list_new (void);
62 
68 AnxList * anx_list_clone (AnxList * list);
69 
77 
83 AnxList * anx_list_tail (AnxList * list);
84 
91 AnxList * anx_list_prepend (AnxList * list, void * data);
92 
99 AnxList * anx_list_append (AnxList * list, void * data);
100 
108 AnxList * anx_list_add_before (AnxList * list, void * data, AnxList * node);
109 
117 AnxList * anx_list_add_after (AnxList * list, void * data, AnxList * node);
118 
125 AnxList * anx_list_find (AnxList * list, void * data);
126 
133 AnxList * anx_list_remove (AnxList * list, AnxList * node);
134 
140 int anx_list_length (AnxList * list);
141 
147 int anx_list_is_empty (AnxList * list);
148 
154 int anx_list_is_singleton (AnxList * list);
155 
162 AnxList * anx_list_free_with (AnxList * list, AnxFreeFunc free_func);
163 
169 AnxList * anx_list_free (AnxList * list);
170 
171 #ifdef __cplusplus
172 }
173 #endif
174 
175 #endif /* __ANX_LIST_H__ */
anx_list_clone_with
AnxList * anx_list_clone_with(AnxList *list, AnxCloneFunc clone)
Clone a list using a custom clone function.
anx_list_free_with
AnxList * anx_list_free_with(AnxList *list, AnxFreeFunc free_func)
Free a list, using a given function to free each data element.
anx_list_clone
AnxList * anx_list_clone(AnxList *list)
Clone a list using the default clone function.
anx_list_find
AnxList * anx_list_find(AnxList *list, void *data)
Find the first node containing given data in a list.
anx_list_prepend
AnxList * anx_list_prepend(AnxList *list, void *data)
Prepend a new node to a list containing given data.
anx_list_tail
AnxList * anx_list_tail(AnxList *list)
Return the tail element of a list.
AnxCloneFunc
void *(* AnxCloneFunc)(void *data)
Signature of a cloning function.
Definition: anx_core.h:51
anx_list_add_after
AnxList * anx_list_add_after(AnxList *list, void *data, AnxList *node)
Add a new node containing given data after a given node.
AnxFreeFunc
void *(* AnxFreeFunc)(void *data)
Signature of a freeing function.
Definition: anx_core.h:56
anx_list_remove
AnxList * anx_list_remove(AnxList *list, AnxList *node)
Remove a node from a list.
anx_list_free
AnxList * anx_list_free(AnxList *list)
Free a list, using anx_free() to free each data element.
anx_list_length
int anx_list_length(AnxList *list)
Query the number of items in a list.
_AnxList
Definition: anx_list.h:47
anx_list_is_singleton
int anx_list_is_singleton(AnxList *list)
Query if the list is singleton, ie.
anx_core.h
anx_list_add_before
AnxList * anx_list_add_before(AnxList *list, void *data, AnxList *node)
Add a new node containing given data before a given node.
anx_list_append
AnxList * anx_list_append(AnxList *list, void *data)
Append a new node to a list containing given data.
anx_list_new
AnxList * anx_list_new(void)
Create a new list.
anx_list_is_empty
int anx_list_is_empty(AnxList *list)
Query if a list is empty, ie.