1 /* 2 * alpm_list.h 3 * 4 * Copyright (c) 2006-2019 Pacman Development Team <pacman-dev@archlinux.org> 5 * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org> 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 module alpm.alpm_list; 21 22 extern (C): 23 24 /* size_t */ 25 26 /* Note: alpm_list.{c,h} are intended to be standalone files. Do not include 27 * any other libalpm headers. 28 */ 29 30 /** 31 * @brief Linked list type used by libalpm. 32 * 33 * It is exposed so front ends can use it to prevent the need to reimplement 34 * lists of their own; however, it is not required that the front end uses 35 * it. 36 */ 37 struct __alpm_list_t 38 { 39 /** data held by the list node */ 40 void* data; 41 /** pointer to the previous node */ 42 __alpm_list_t* prev; 43 /** pointer to the next node */ 44 __alpm_list_t* next; 45 } 46 47 alias alpm_list_t = __alpm_list_t; 48 49 alias alpm_list_fn_free = void function (void*); /* item deallocation callback */ 50 alias alpm_list_fn_cmp = int function (const(void)*, const(void)*); /* item comparison callback */ 51 52 /* allocation */ 53 void alpm_list_free (alpm_list_t* list); 54 void alpm_list_free_inner (alpm_list_t* list, alpm_list_fn_free fn); 55 56 /* item mutators */ 57 alpm_list_t* alpm_list_add (alpm_list_t* list, void* data); 58 alpm_list_t* alpm_list_append (alpm_list_t** list, void* data); 59 alpm_list_t* alpm_list_append_strdup (alpm_list_t** list, const(char)* data); 60 alpm_list_t* alpm_list_add_sorted (alpm_list_t* list, void* data, alpm_list_fn_cmp fn); 61 alpm_list_t* alpm_list_join (alpm_list_t* first, alpm_list_t* second); 62 alpm_list_t* alpm_list_mmerge (alpm_list_t* left, alpm_list_t* right, alpm_list_fn_cmp fn); 63 alpm_list_t* alpm_list_msort (alpm_list_t* list, size_t n, alpm_list_fn_cmp fn); 64 alpm_list_t* alpm_list_remove_item (alpm_list_t* haystack, alpm_list_t* item); 65 alpm_list_t* alpm_list_remove (alpm_list_t* haystack, const(void)* needle, alpm_list_fn_cmp fn, void** data); 66 alpm_list_t* alpm_list_remove_str (alpm_list_t* haystack, const(char)* needle, char** data); 67 alpm_list_t* alpm_list_remove_dupes (const(alpm_list_t)* list); 68 alpm_list_t* alpm_list_strdup (const(alpm_list_t)* list); 69 alpm_list_t* alpm_list_copy (const(alpm_list_t)* list); 70 alpm_list_t* alpm_list_copy_data (const(alpm_list_t)* list, size_t size); 71 alpm_list_t* alpm_list_reverse (alpm_list_t* list); 72 73 /* item accessors */ 74 alpm_list_t* alpm_list_nth (const(alpm_list_t)* list, size_t n); 75 alpm_list_t* alpm_list_next (const(alpm_list_t)* list); 76 alpm_list_t* alpm_list_previous (const(alpm_list_t)* list); 77 alpm_list_t* alpm_list_last (const(alpm_list_t)* list); 78 79 /* misc */ 80 size_t alpm_list_count (const(alpm_list_t)* list); 81 void* alpm_list_find (const(alpm_list_t)* haystack, const(void)* needle, alpm_list_fn_cmp fn); 82 void* alpm_list_find_ptr (const(alpm_list_t)* haystack, const(void)* needle); 83 char* alpm_list_find_str (const(alpm_list_t)* haystack, const(char)* needle); 84 alpm_list_t* alpm_list_diff (const(alpm_list_t)* lhs, const(alpm_list_t)* rhs, alpm_list_fn_cmp fn); 85 void alpm_list_diff_sorted ( 86 const(alpm_list_t)* left, 87 const(alpm_list_t)* right, 88 alpm_list_fn_cmp fn, 89 alpm_list_t** onlyleft, 90 alpm_list_t** onlyright); 91 void* alpm_list_to_array (const(alpm_list_t)* list, size_t n, size_t size); 92 93 /* ALPM_LIST_H */