1 /*************************************************************************** 2 begin : Mon Mar 01 2004 3 copyright : (C) 2020 by Martin Preuss 4 email : martin@libchipcard.de 5 6 *************************************************************************** 7 * * 8 * This library is free software; you can redistribute it and/or * 9 * modify it under the terms of the GNU Lesser General Public * 10 * License as published by the Free Software Foundation; either * 11 * version 2.1 of the License, or (at your option) any later version. * 12 * * 13 * This library is distributed in the hope that it will be useful, * 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 16 * Lesser General Public License for more details. * 17 * * 18 * You should have received a copy of the GNU Lesser General Public * 19 * License along with this library; if not, write to the Free Software * 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * 21 * MA 02111-1307 USA * 22 * * 23 ***************************************************************************/ 24 25 /** @file idlist.h 26 * @short A list of uint64_t objects 27 */ 28 29 30 #ifndef GWENHYWFAR_IDLIST64_H 31 #define GWENHYWFAR_IDLIST64_H 32 33 34 #include <gwenhywfar/gwenhywfarapi.h> 35 #include <gwenhywfar/types.h> 36 #include <gwenhywfar/simpleptrlist.h> 37 38 39 #ifdef __cplusplus 40 extern "C" { 41 #endif 42 typedef GWEN_SIMPLEPTRLIST GWEN_IDLIST64; 43 typedef struct GWEN_IDLIST64_ITERATOR GWEN_IDLIST64_ITERATOR; 44 #ifdef __cplusplus 45 } 46 #endif 47 48 49 #ifdef __cplusplus 50 extern "C" { 51 #endif 52 53 54 55 /** 56 * @defgroup MOD_IDLIST64 ID list module 57 * @ingroup MOD_BASE 58 * @short A list of uint64_t objects 59 * 60 * This is basically a list for uint64_t objects, 61 * but since it uses tables instead of those list objects normally used 62 * throughout Gwen it is less memory consuming. 63 */ 64 /*@{*/ 65 66 67 68 GWENHYWFAR_API GWEN_IDLIST64 *GWEN_IdList64_new(void); 69 GWENHYWFAR_API GWEN_IDLIST64 *GWEN_IdList64_newWithSteps(uint64_t steps); 70 GWENHYWFAR_API void GWEN_IdList64_Attach(GWEN_IDLIST64 *idl); 71 GWENHYWFAR_API void GWEN_IdList64_free(GWEN_IDLIST64 *idl); 72 73 GWENHYWFAR_API void GWEN_IdList64_Clear(GWEN_IDLIST64 *idl); 74 75 GWENHYWFAR_API GWEN_IDLIST64 *GWEN_IdList64_dup(const GWEN_IDLIST64 *oldList); 76 GWENHYWFAR_API GWEN_IDLIST64 *GWEN_IdList64_LazyCopy(GWEN_IDLIST64 *oldList); 77 78 /** 79 * Adds an id to the list, returns its index. This function does no doublecheck. 80 */ 81 GWENHYWFAR_API int64_t GWEN_IdList64_AddId(GWEN_IDLIST64 *idl, uint64_t id); 82 83 /** 84 * Removes the first occurrence of the given id. 85 * @return 0 if deleted, !=0 if the id wasn't found 86 */ 87 GWENHYWFAR_API int GWEN_IdList64_DelId(GWEN_IDLIST64 *idl, uint64_t id); 88 89 /** 90 * Checks whether the given id exists in the idlist. 91 * @return 1 if found, 0 otherwise 92 */ 93 GWENHYWFAR_API int GWEN_IdList64_HasId(const GWEN_IDLIST64 *idl, uint64_t id); 94 95 GWENHYWFAR_API int64_t GWEN_IdList64_GetIdAt(const GWEN_IDLIST64 *idl, uint64_t index); 96 97 98 GWENHYWFAR_API uint64_t GWEN_IdList64_GetEntryCount(const GWEN_IDLIST64 *idl); 99 100 /** 101 * Sorts the ids in ascending order 102 */ 103 GWENHYWFAR_API int GWEN_IdList64_Sort(GWEN_IDLIST64 *idl); 104 105 106 GWENHYWFAR_API int GWEN_IdList64_ReverseSort(GWEN_IDLIST64 *idl); 107 108 109 /*@}*/ 110 111 112 113 /** 114 * @defgroup MOD_IDLIST64_ITERATOR Iterator for ID list module 115 * @ingroup MOD_BASE 116 * @short Iterator for a list of uint64_t objects 117 * 118 */ 119 /*@{*/ 120 121 GWENHYWFAR_API GWEN_IDLIST64_ITERATOR *GWEN_IdList64_Iterator_new(const GWEN_IDLIST64 *idl); 122 123 GWENHYWFAR_API void GWEN_IdList64_Iterator_free(GWEN_IDLIST64_ITERATOR *it); 124 125 GWENHYWFAR_API uint64_t GWEN_IdList64_Iterator_GetFirstId(GWEN_IDLIST64_ITERATOR *it); 126 127 GWENHYWFAR_API uint64_t GWEN_IdList64_Iterator_GetNextId(GWEN_IDLIST64_ITERATOR *it); 128 129 /*@}*/ 130 131 132 133 #ifdef __cplusplus 134 } 135 #endif 136 137 138 #endif /* GWENHYWFAR_IDLIST64_H */ 139 140 141