1/*************************************************************************** 2 $RCSfile$ 3 ------------------- 4 cvs : $Id$ 5 begin : Sat Jun 28 2003 6 copyright : (C) 2003 by Martin Preuss 7 email : martin@libchipcard.de 8 9 *************************************************************************** 10 * * 11 * This library is free software; you can redistribute it and/or * 12 * modify it under the terms of the GNU Lesser General Public * 13 * License as published by the Free Software Foundation; either * 14 * version 2.1 of the License, or (at your option) any later version. * 15 * * 16 * This library is distributed in the hope that it will be useful, * 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 19 * Lesser General Public License for more details. * 20 * * 21 * You should have received a copy of the GNU Lesser General Public * 22 * License along with this library; if not, write to the Free Software * 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * 24 * MA 02111-1307 USA * 25 * * 26 ***************************************************************************/ 27 28 29#ifndef @TYPENAME@_LIST1_H 30#define @TYPENAME@_LIST1_H 31 32#ifdef __cplusplus 33extern "C" { 34#endif 35 36 /** @internal */ 37 typedef struct @TYPENAME@_LIST_ELEMENT { 38 uint32_t id; 39 @TYPENAME@ *nextObject; 40 } @TYPENAME@_LIST__ELEMENT; 41 42 /** 43 * This represents a list of @TYPENAME@ (see @ref @FN_PREFIX@_List_new). 44 * This list may contain any number of elements. However, every element can 45 * only exist within a single list. 46 * If you need a better list please check @ref GWEN_LIST. 47 */ 48 typedef struct @TYPENAME@_LIST @TYPENAME@_LIST; 49 50 /** 51 * This function is called from within @ref @FN_PREFIX@_List_SetSortFn(). 52 */ 53 typedef int GWENHYWFAR_CB (*@TYPENAME@_LIST_SORT_FN)(const @TYPENAME@ *a, const @TYPENAME@ *b, int ascending); 54 55 56 /** @internal */ 57 struct @TYPENAME@_LIST { 58 @TYPENAME@ *first; 59 uint32_t count; 60 uint32_t id; 61 } @TYPENAME@_LIST; 62 63 /** 64 * Moves the content of one list to another list thus leaving the 65 * old list empty. 66 */ 67 void @FN_PREFIX@_List_AddList(@TYPENAME@_LIST *dst, @TYPENAME@_LIST *l); 68 69 /** 70 * Adds the given element to the given list making it the new tail. 71 */ 72 void @FN_PREFIX@_List_Add(@TYPENAME@ *element, @TYPENAME@_LIST *list); 73 74 /** 75 * Inserts the given element into the given list thus making it the new 76 * head of the list. 77 */ 78 void @FN_PREFIX@_List_Insert(@TYPENAME@ *element, @TYPENAME@_LIST *list); 79 80 /** 81 * Unlinks the given element from whatever list it may currently be 82 * enlisted. If the element is @b not member of any list the program is 83 * aborted. 84 * Please note: The element is just unlinked, not deleted. 85 */ 86 void @FN_PREFIX@_List_Del(@TYPENAME@ *element); 87 88 /** 89 * Returns the first element of the list. 90 */ 91 @TYPENAME@* @FN_PREFIX@_List_First(const @TYPENAME@_LIST *l); 92 93 /** 94 * Returns the last element of the list. 95 */ 96 @TYPENAME@* @FN_PREFIX@_List_Last(const @TYPENAME@_LIST *l); 97 98 /** 99 * Clears the given list (thus leaving it empty). All elements of this list 100 * are deleted via @ref @FN_PREFIX@_free(); 101 */ 102 void @FN_PREFIX@_List_Clear(@TYPENAME@_LIST *l); 103 104 /** 105 * Creates a new list of @ref @TYPENAME@. 106 */ 107 @TYPENAME@_LIST* @FN_PREFIX@_List_new(); 108 109 /** 110 * Destroys the list and frees all its elements. 111 */ 112 void @FN_PREFIX@_List_free(@TYPENAME@_LIST *l); 113 114 /** 115 * Returns the successor of the given element. 116 */ 117 @TYPENAME@* @FN_PREFIX@_List_Next(const @TYPENAME@ *element); 118 119 /** 120 * Returns the predecessor of the given element. 121 */ 122 @TYPENAME@* @FN_PREFIX@_List_Previous(const @TYPENAME@ *element); 123 124 /** 125 * Returns the number of elements currently in the given list. 126 */ 127 uint32_t @FN_PREFIX@_List_GetCount(const @TYPENAME@_LIST *l); 128 129 /** 130 * Set the sort function for the next calls to @ref @FN_PREFIX@_List_Sort(). 131 */ 132 @TYPENAME@_LIST_SORT_FN @FN_PREFIX@_List_SetSortFn(@TYPENAME@_LIST *l, @TYPENAME@_LIST_SORT_FN fn); 133 134 /** 135 * Sort the list. Within the course of this function the sort function set via 136 * @ref @FN_PREFIX@_List_SetSortFn is called with the arguments 137 * "const @TYPENAME@ *a, const @TYPENAME@ *b, int ascending". 138 */ 139 void @FN_PREFIX@_List_Sort(@TYPENAME@_LIST *l, int ascending); 140 141 142#ifdef __cplusplus 143} 144#endif 145 146 147#endif 148 149 150 151