Pratyush Mallick
/
nano_dac
this is testing
noos_mbed/include/list.h@0:e8a1ba50c46b, 2021-01-14 (annotated)
- Committer:
- pmallick
- Date:
- Thu Jan 14 19:12:57 2021 +0530
- Revision:
- 0:e8a1ba50c46b
this is testing
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pmallick | 0:e8a1ba50c46b | 1 | /***************************************************************************//** |
pmallick | 0:e8a1ba50c46b | 2 | * @file list.h |
pmallick | 0:e8a1ba50c46b | 3 | * @brief List library header |
pmallick | 0:e8a1ba50c46b | 4 | * @author Mihail Chindris (mihail.chindris@analog.com) |
pmallick | 0:e8a1ba50c46b | 5 | ******************************************************************************** |
pmallick | 0:e8a1ba50c46b | 6 | * @copyright |
pmallick | 0:e8a1ba50c46b | 7 | * Copyright 2020(c) Analog Devices, Inc. |
pmallick | 0:e8a1ba50c46b | 8 | * |
pmallick | 0:e8a1ba50c46b | 9 | * All rights reserved. |
pmallick | 0:e8a1ba50c46b | 10 | * |
pmallick | 0:e8a1ba50c46b | 11 | * Redistribution and use in source and binary forms, with or without |
pmallick | 0:e8a1ba50c46b | 12 | * modification, are permitted provided that the following conditions are met: |
pmallick | 0:e8a1ba50c46b | 13 | * - Redistributions of source code must retain the above copyright |
pmallick | 0:e8a1ba50c46b | 14 | * notice, this list of conditions and the following disclaimer. |
pmallick | 0:e8a1ba50c46b | 15 | * - Redistributions in binary form must reproduce the above copyright |
pmallick | 0:e8a1ba50c46b | 16 | * notice, this list of conditions and the following disclaimer in |
pmallick | 0:e8a1ba50c46b | 17 | * the documentation and/or other materials provided with the |
pmallick | 0:e8a1ba50c46b | 18 | * distribution. |
pmallick | 0:e8a1ba50c46b | 19 | * - Neither the name of Analog Devices, Inc. nor the names of its |
pmallick | 0:e8a1ba50c46b | 20 | * contributors may be used to endorse or promote products derived |
pmallick | 0:e8a1ba50c46b | 21 | * from this software without specific prior written permission. |
pmallick | 0:e8a1ba50c46b | 22 | * - The use of this software may or may not infringe the patent rights |
pmallick | 0:e8a1ba50c46b | 23 | * of one or more patent holders. This license does not release you |
pmallick | 0:e8a1ba50c46b | 24 | * from the requirement that you obtain separate licenses from these |
pmallick | 0:e8a1ba50c46b | 25 | * patent holders to use this software. |
pmallick | 0:e8a1ba50c46b | 26 | * - Use of the software either in source or binary form, must be run |
pmallick | 0:e8a1ba50c46b | 27 | * on or directly connected to an Analog Devices Inc. component. |
pmallick | 0:e8a1ba50c46b | 28 | * |
pmallick | 0:e8a1ba50c46b | 29 | * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR |
pmallick | 0:e8a1ba50c46b | 30 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, |
pmallick | 0:e8a1ba50c46b | 31 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
pmallick | 0:e8a1ba50c46b | 32 | * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, |
pmallick | 0:e8a1ba50c46b | 33 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
pmallick | 0:e8a1ba50c46b | 34 | * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR |
pmallick | 0:e8a1ba50c46b | 35 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
pmallick | 0:e8a1ba50c46b | 36 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
pmallick | 0:e8a1ba50c46b | 37 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
pmallick | 0:e8a1ba50c46b | 38 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
pmallick | 0:e8a1ba50c46b | 39 | ******************************************************************************** |
pmallick | 0:e8a1ba50c46b | 40 | * |
pmallick | 0:e8a1ba50c46b | 41 | * @section list_details Library description |
pmallick | 0:e8a1ba50c46b | 42 | * This library handles double linked lists and it expose inseart, |
pmallick | 0:e8a1ba50c46b | 43 | * read, get and delete functions. \n |
pmallick | 0:e8a1ba50c46b | 44 | * It also can be accesed using it member functions which wrapp function for |
pmallick | 0:e8a1ba50c46b | 45 | * usual list types.\n |
pmallick | 0:e8a1ba50c46b | 46 | * @subsection example Sample code |
pmallick | 0:e8a1ba50c46b | 47 | * @code{.c} |
pmallick | 0:e8a1ba50c46b | 48 | * // -- Use a generic list |
pmallick | 0:e8a1ba50c46b | 49 | * struct list_desc *list1; |
pmallick | 0:e8a1ba50c46b | 50 | * struct iterator *it; |
pmallick | 0:e8a1ba50c46b | 51 | * uint32_t a; |
pmallick | 0:e8a1ba50c46b | 52 | * // Create list list1 |
pmallick | 0:e8a1ba50c46b | 53 | * list_init(&list1, LIST_DEFAULT, NULL); |
pmallick | 0:e8a1ba50c46b | 54 | * // Add items to the list |
pmallick | 0:e8a1ba50c46b | 55 | * list_add_last(list1, 1); |
pmallick | 0:e8a1ba50c46b | 56 | * list_add_last(list1, 2); |
pmallick | 0:e8a1ba50c46b | 57 | * list_add_last(list1, 3); |
pmallick | 0:e8a1ba50c46b | 58 | * // Here the list will be: 1 -> 2 - > 3 |
pmallick | 0:e8a1ba50c46b | 59 | * |
pmallick | 0:e8a1ba50c46b | 60 | * list_read_last(list1, &a); |
pmallick | 0:e8a1ba50c46b | 61 | * printf("Last: %d\n", a); |
pmallick | 0:e8a1ba50c46b | 62 | * // 3 will be printed |
pmallick | 0:e8a1ba50c46b | 63 | * // Create an iterator on the end of the list |
pmallick | 0:e8a1ba50c46b | 64 | * iterator_init(&it, list1, 0); |
pmallick | 0:e8a1ba50c46b | 65 | * // Move the iterator backword with one position |
pmallick | 0:e8a1ba50c46b | 66 | * iterator_move(it, -1); |
pmallick | 0:e8a1ba50c46b | 67 | * // Read the data at the current position |
pmallick | 0:e8a1ba50c46b | 68 | * iterator_read(it, &a); |
pmallick | 0:e8a1ba50c46b | 69 | * printf("Current: %d\n", a); |
pmallick | 0:e8a1ba50c46b | 70 | * // 2 will be printed |
pmallick | 0:e8a1ba50c46b | 71 | * iterator_remove(it); |
pmallick | 0:e8a1ba50c46b | 72 | * list_remove(list1); |
pmallick | 0:e8a1ba50c46b | 73 | * |
pmallick | 0:e8a1ba50c46b | 74 | * // -- Use a popular list |
pmallick | 0:e8a1ba50c46b | 75 | * struct list_desc *stack; |
pmallick | 0:e8a1ba50c46b | 76 | * // Create a FIFO list |
pmallick | 0:e8a1ba50c46b | 77 | * list_init(&stack, LIST_STACK, NULL); |
pmallick | 0:e8a1ba50c46b | 78 | * // Put elements in the list |
pmallick | 0:e8a1ba50c46b | 79 | * stack->push(stack, 1); |
pmallick | 0:e8a1ba50c46b | 80 | * stack->push(stack, 2); |
pmallick | 0:e8a1ba50c46b | 81 | * stack->push(stack, 3); |
pmallick | 0:e8a1ba50c46b | 82 | * // Read from the stack |
pmallick | 0:e8a1ba50c46b | 83 | * stack->pop(stack, &a); |
pmallick | 0:e8a1ba50c46b | 84 | * printf("Last: %d\n", a); |
pmallick | 0:e8a1ba50c46b | 85 | * // 3 will be printed |
pmallick | 0:e8a1ba50c46b | 86 | * list_remove(stack); |
pmallick | 0:e8a1ba50c46b | 87 | * @endcode |
pmallick | 0:e8a1ba50c46b | 88 | *******************************************************************************/ |
pmallick | 0:e8a1ba50c46b | 89 | |
pmallick | 0:e8a1ba50c46b | 90 | #ifndef LIST_H |
pmallick | 0:e8a1ba50c46b | 91 | #define LIST_H |
pmallick | 0:e8a1ba50c46b | 92 | |
pmallick | 0:e8a1ba50c46b | 93 | /******************************************************************************/ |
pmallick | 0:e8a1ba50c46b | 94 | /***************************** Include Files **********************************/ |
pmallick | 0:e8a1ba50c46b | 95 | /******************************************************************************/ |
pmallick | 0:e8a1ba50c46b | 96 | |
pmallick | 0:e8a1ba50c46b | 97 | #include <stdint.h> |
pmallick | 0:e8a1ba50c46b | 98 | #include <stdbool.h> |
pmallick | 0:e8a1ba50c46b | 99 | |
pmallick | 0:e8a1ba50c46b | 100 | /******************************************************************************/ |
pmallick | 0:e8a1ba50c46b | 101 | /*************************** Types Declarations *******************************/ |
pmallick | 0:e8a1ba50c46b | 102 | /******************************************************************************/ |
pmallick | 0:e8a1ba50c46b | 103 | |
pmallick | 0:e8a1ba50c46b | 104 | /** |
pmallick | 0:e8a1ba50c46b | 105 | * @struct list_desc |
pmallick | 0:e8a1ba50c46b | 106 | * @brief Structure storing the list and function wrapper for usual list types |
pmallick | 0:e8a1ba50c46b | 107 | * |
pmallick | 0:e8a1ba50c46b | 108 | * With this structure the funtionalities of usual list types |
pmallick | 0:e8a1ba50c46b | 109 | * ( \ref adapter_type ) can be accesed with the functions referenced in this |
pmallick | 0:e8a1ba50c46b | 110 | * structure. |
pmallick | 0:e8a1ba50c46b | 111 | * For example: |
pmallick | 0:e8a1ba50c46b | 112 | * @code{.c} |
pmallick | 0:e8a1ba50c46b | 113 | * my_queue->push(my_queue, my_data); |
pmallick | 0:e8a1ba50c46b | 114 | * @endcode |
pmallick | 0:e8a1ba50c46b | 115 | */ |
pmallick | 0:e8a1ba50c46b | 116 | struct list_desc; |
pmallick | 0:e8a1ba50c46b | 117 | |
pmallick | 0:e8a1ba50c46b | 118 | /** |
pmallick | 0:e8a1ba50c46b | 119 | * @struct list_iterator |
pmallick | 0:e8a1ba50c46b | 120 | * @brief Structure used to iterate through the list using Iterator functions. |
pmallick | 0:e8a1ba50c46b | 121 | */ |
pmallick | 0:e8a1ba50c46b | 122 | struct iterator; |
pmallick | 0:e8a1ba50c46b | 123 | |
pmallick | 0:e8a1ba50c46b | 124 | /** |
pmallick | 0:e8a1ba50c46b | 125 | * @brief Prototype of the compare function. |
pmallick | 0:e8a1ba50c46b | 126 | * |
pmallick | 0:e8a1ba50c46b | 127 | * The function used to compare the elements of the liste when doing |
pmallick | 0:e8a1ba50c46b | 128 | * operations on an ordered list. |
pmallick | 0:e8a1ba50c46b | 129 | * @param data1 - First element to be compared |
pmallick | 0:e8a1ba50c46b | 130 | * @param data2 - Second element to be compared |
pmallick | 0:e8a1ba50c46b | 131 | * @return |
pmallick | 0:e8a1ba50c46b | 132 | * - -1 - If data1 < data2 |
pmallick | 0:e8a1ba50c46b | 133 | * - 0 - If data1 == data2 |
pmallick | 0:e8a1ba50c46b | 134 | * - 1 - If data1 > data2 |
pmallick | 0:e8a1ba50c46b | 135 | */ |
pmallick | 0:e8a1ba50c46b | 136 | typedef int32_t (*f_cmp)(void *data1, void *data2); |
pmallick | 0:e8a1ba50c46b | 137 | |
pmallick | 0:e8a1ba50c46b | 138 | /** |
pmallick | 0:e8a1ba50c46b | 139 | * @name Generic functions |
pmallick | 0:e8a1ba50c46b | 140 | * Each function interacting with the list have one of the following formats.\n |
pmallick | 0:e8a1ba50c46b | 141 | * Aditionaly they may have one more parametere for specific functionalities.\n |
pmallick | 0:e8a1ba50c46b | 142 | * In the Iterator functions, the list reference is replaced by the iterator's |
pmallick | 0:e8a1ba50c46b | 143 | * one. |
pmallick | 0:e8a1ba50c46b | 144 | * @{ |
pmallick | 0:e8a1ba50c46b | 145 | */ |
pmallick | 0:e8a1ba50c46b | 146 | |
pmallick | 0:e8a1ba50c46b | 147 | /** |
pmallick | 0:e8a1ba50c46b | 148 | * @brief Add an element in the list. |
pmallick | 0:e8a1ba50c46b | 149 | * |
pmallick | 0:e8a1ba50c46b | 150 | * The element of the list is created and the data field is stored in it. |
pmallick | 0:e8a1ba50c46b | 151 | * @param list_desc - Reference to the list. Created by \ref list_init |
pmallick | 0:e8a1ba50c46b | 152 | * @param data - Data to store in a list element |
pmallick | 0:e8a1ba50c46b | 153 | * @return |
pmallick | 0:e8a1ba50c46b | 154 | * - \ref SUCCESS : On success |
pmallick | 0:e8a1ba50c46b | 155 | * - \ref FAILURE : Otherwise |
pmallick | 0:e8a1ba50c46b | 156 | */ |
pmallick | 0:e8a1ba50c46b | 157 | typedef int32_t (*f_add)(struct list_desc *list_desc, void *data); |
pmallick | 0:e8a1ba50c46b | 158 | |
pmallick | 0:e8a1ba50c46b | 159 | /** |
pmallick | 0:e8a1ba50c46b | 160 | * @brief Edit an element in the list. The content is replaced by new_data. |
pmallick | 0:e8a1ba50c46b | 161 | * @param list_desc - Reference to the list. Created by \ref list_init . |
pmallick | 0:e8a1ba50c46b | 162 | * @param new_data - New data to replace the old one |
pmallick | 0:e8a1ba50c46b | 163 | * @return |
pmallick | 0:e8a1ba50c46b | 164 | * - \ref SUCCESS : On success |
pmallick | 0:e8a1ba50c46b | 165 | * - \ref FAILURE : Otherwise |
pmallick | 0:e8a1ba50c46b | 166 | */ |
pmallick | 0:e8a1ba50c46b | 167 | typedef int32_t (*f_edit)(struct list_desc *list_desc, void *new_data); |
pmallick | 0:e8a1ba50c46b | 168 | |
pmallick | 0:e8a1ba50c46b | 169 | /** |
pmallick | 0:e8a1ba50c46b | 170 | * @brief Read an element from the list. |
pmallick | 0:e8a1ba50c46b | 171 | * @param list_desc - Reference to the list. Created by \ref list_init |
pmallick | 0:e8a1ba50c46b | 172 | * @param result - If not null, result is filled with: |
pmallick | 0:e8a1ba50c46b | 173 | * @param data - Content of the list element, NULL if some error occur. |
pmallick | 0:e8a1ba50c46b | 174 | * @return \n |
pmallick | 0:e8a1ba50c46b | 175 | * - \ref SUCCESS : On success |
pmallick | 0:e8a1ba50c46b | 176 | * - \ref FAILURE : Otherwise |
pmallick | 0:e8a1ba50c46b | 177 | * @note If the content of an element can be 0 then the result must be checked |
pmallick | 0:e8a1ba50c46b | 178 | * to see if the functions has succeded |
pmallick | 0:e8a1ba50c46b | 179 | */ |
pmallick | 0:e8a1ba50c46b | 180 | typedef int32_t (*f_read)(struct list_desc *list_desc, void **data); |
pmallick | 0:e8a1ba50c46b | 181 | |
pmallick | 0:e8a1ba50c46b | 182 | /** |
pmallick | 0:e8a1ba50c46b | 183 | * @brief Read and remove an element from the list. |
pmallick | 0:e8a1ba50c46b | 184 | * @param list_desc - Reference to the list. Created by \ref list_init |
pmallick | 0:e8a1ba50c46b | 185 | * @param result - If not null, result is filled with: |
pmallick | 0:e8a1ba50c46b | 186 | * @param data - Content of the list element, NULL if some error occur. |
pmallick | 0:e8a1ba50c46b | 187 | * @return |
pmallick | 0:e8a1ba50c46b | 188 | * - \ref SUCCESS : On success |
pmallick | 0:e8a1ba50c46b | 189 | * - \ref FAILURE : Otherwise |
pmallick | 0:e8a1ba50c46b | 190 | */ |
pmallick | 0:e8a1ba50c46b | 191 | typedef int32_t (*f_get)(struct list_desc *list_desc, void **data); |
pmallick | 0:e8a1ba50c46b | 192 | |
pmallick | 0:e8a1ba50c46b | 193 | /** @} */ |
pmallick | 0:e8a1ba50c46b | 194 | |
pmallick | 0:e8a1ba50c46b | 195 | /** |
pmallick | 0:e8a1ba50c46b | 196 | * @enum adapter_type |
pmallick | 0:e8a1ba50c46b | 197 | * @brief Selects functionalities for functions in \ref list_desc |
pmallick | 0:e8a1ba50c46b | 198 | */ |
pmallick | 0:e8a1ba50c46b | 199 | enum adapter_type { |
pmallick | 0:e8a1ba50c46b | 200 | /** Default type is LIST_STACK */ |
pmallick | 0:e8a1ba50c46b | 201 | LIST_DEFAULT, |
pmallick | 0:e8a1ba50c46b | 202 | /** |
pmallick | 0:e8a1ba50c46b | 203 | * Functions for a FIFO list (First-in first-out). Elements are inserted |
pmallick | 0:e8a1ba50c46b | 204 | * in one end and extracted from the other end. |
pmallick | 0:e8a1ba50c46b | 205 | * - \e Push: Insert element |
pmallick | 0:e8a1ba50c46b | 206 | * - \e Pop: Get next element (Read and remove) |
pmallick | 0:e8a1ba50c46b | 207 | * - \e Top_next: Read next element |
pmallick | 0:e8a1ba50c46b | 208 | * - \e Back: Read first element |
pmallick | 0:e8a1ba50c46b | 209 | * - \e Swap: Edit the content of the next element |
pmallick | 0:e8a1ba50c46b | 210 | */ |
pmallick | 0:e8a1ba50c46b | 211 | LIST_QUEUE, |
pmallick | 0:e8a1ba50c46b | 212 | /** |
pmallick | 0:e8a1ba50c46b | 213 | * Functions for a LIFO list (Last-in first-out). Elements are inserted |
pmallick | 0:e8a1ba50c46b | 214 | * and extracted only from the same end. |
pmallick | 0:e8a1ba50c46b | 215 | * - \e Push: Insert element |
pmallick | 0:e8a1ba50c46b | 216 | * - \e Pop: Get top element (Read and remove) |
pmallick | 0:e8a1ba50c46b | 217 | * - \e Top_next: Read top element |
pmallick | 0:e8a1ba50c46b | 218 | * - \e Back: Read bottom element |
pmallick | 0:e8a1ba50c46b | 219 | * - \e Swap: Edit the content of the top element |
pmallick | 0:e8a1ba50c46b | 220 | */ |
pmallick | 0:e8a1ba50c46b | 221 | LIST_STACK, |
pmallick | 0:e8a1ba50c46b | 222 | /** |
pmallick | 0:e8a1ba50c46b | 223 | * Functions for ordered list. The order of element is determinated |
pmallick | 0:e8a1ba50c46b | 224 | * usinge the \ref f_cmp. |
pmallick | 0:e8a1ba50c46b | 225 | * - \e Push: Insert element |
pmallick | 0:e8a1ba50c46b | 226 | * - \e Pop: Get lowest element (Read and remove) |
pmallick | 0:e8a1ba50c46b | 227 | * - \e Top_next: Read lowest element |
pmallick | 0:e8a1ba50c46b | 228 | * - \e Back: Read the biggest element |
pmallick | 0:e8a1ba50c46b | 229 | * - \e Swap: Edit the lowest element |
pmallick | 0:e8a1ba50c46b | 230 | */ |
pmallick | 0:e8a1ba50c46b | 231 | LIST_PRIORITY_LIST |
pmallick | 0:e8a1ba50c46b | 232 | }; |
pmallick | 0:e8a1ba50c46b | 233 | |
pmallick | 0:e8a1ba50c46b | 234 | struct list_desc { |
pmallick | 0:e8a1ba50c46b | 235 | /** Refer to \ref adapter_type */ |
pmallick | 0:e8a1ba50c46b | 236 | f_add push; |
pmallick | 0:e8a1ba50c46b | 237 | /** Refer to \ref adapter_type */ |
pmallick | 0:e8a1ba50c46b | 238 | f_get pop; |
pmallick | 0:e8a1ba50c46b | 239 | /** Refer to \ref adapter_type */ |
pmallick | 0:e8a1ba50c46b | 240 | f_read top_next; |
pmallick | 0:e8a1ba50c46b | 241 | /** Refer to \ref adapter_type */ |
pmallick | 0:e8a1ba50c46b | 242 | f_read back; |
pmallick | 0:e8a1ba50c46b | 243 | /** Refer to \ref adapter_type */ |
pmallick | 0:e8a1ba50c46b | 244 | f_edit swap; |
pmallick | 0:e8a1ba50c46b | 245 | /** Structure storing the list internal parameters */ |
pmallick | 0:e8a1ba50c46b | 246 | void *priv_desc; |
pmallick | 0:e8a1ba50c46b | 247 | }; |
pmallick | 0:e8a1ba50c46b | 248 | |
pmallick | 0:e8a1ba50c46b | 249 | /******************************************************************************/ |
pmallick | 0:e8a1ba50c46b | 250 | /************************ Functions Declarations ******************************/ |
pmallick | 0:e8a1ba50c46b | 251 | /******************************************************************************/ |
pmallick | 0:e8a1ba50c46b | 252 | |
pmallick | 0:e8a1ba50c46b | 253 | int32_t list_init(struct list_desc **list_desc, enum adapter_type type, |
pmallick | 0:e8a1ba50c46b | 254 | f_cmp comparator); |
pmallick | 0:e8a1ba50c46b | 255 | int32_t list_remove(struct list_desc *list_desc); |
pmallick | 0:e8a1ba50c46b | 256 | int32_t list_get_size(struct list_desc *list_desc, uint32_t *out_size); |
pmallick | 0:e8a1ba50c46b | 257 | |
pmallick | 0:e8a1ba50c46b | 258 | /** |
pmallick | 0:e8a1ba50c46b | 259 | * @name Iterator functions |
pmallick | 0:e8a1ba50c46b | 260 | * An iterator is used to iterate through the list. For a list, any number of |
pmallick | 0:e8a1ba50c46b | 261 | * iterators can be created. All must be removed before removing a list. |
pmallick | 0:e8a1ba50c46b | 262 | * @{ |
pmallick | 0:e8a1ba50c46b | 263 | */ |
pmallick | 0:e8a1ba50c46b | 264 | int32_t iterator_init(struct iterator **iter, struct list_desc *list_desc, |
pmallick | 0:e8a1ba50c46b | 265 | bool start); |
pmallick | 0:e8a1ba50c46b | 266 | int32_t iterator_remove(struct iterator *iter); |
pmallick | 0:e8a1ba50c46b | 267 | int32_t iterator_move(struct iterator *iter, int32_t idx); |
pmallick | 0:e8a1ba50c46b | 268 | int32_t iterator_find(struct iterator *iter, void *cmp_data); |
pmallick | 0:e8a1ba50c46b | 269 | int32_t iterator_insert(struct iterator *iter, void *data, bool after); |
pmallick | 0:e8a1ba50c46b | 270 | int32_t iterator_edit(struct iterator *iter, void *new_data); |
pmallick | 0:e8a1ba50c46b | 271 | int32_t iterator_read(struct iterator *iter, void **data); |
pmallick | 0:e8a1ba50c46b | 272 | int32_t iterator_get(struct iterator *iter, void **data); |
pmallick | 0:e8a1ba50c46b | 273 | /** @}*/ |
pmallick | 0:e8a1ba50c46b | 274 | |
pmallick | 0:e8a1ba50c46b | 275 | /** |
pmallick | 0:e8a1ba50c46b | 276 | * @name Operations on the ends of the list |
pmallick | 0:e8a1ba50c46b | 277 | * These functions will operate on the first or last element of the list |
pmallick | 0:e8a1ba50c46b | 278 | * @{ |
pmallick | 0:e8a1ba50c46b | 279 | */ |
pmallick | 0:e8a1ba50c46b | 280 | int32_t list_add_first(struct list_desc *list_desc, void *data); |
pmallick | 0:e8a1ba50c46b | 281 | int32_t list_edit_first(struct list_desc *list_desc, void *new_data); |
pmallick | 0:e8a1ba50c46b | 282 | int32_t list_read_first(struct list_desc *list_desc, void **data); |
pmallick | 0:e8a1ba50c46b | 283 | int32_t list_get_first(struct list_desc *list_desc, void **data); |
pmallick | 0:e8a1ba50c46b | 284 | |
pmallick | 0:e8a1ba50c46b | 285 | int32_t list_add_last(struct list_desc *list_desc, void *data); |
pmallick | 0:e8a1ba50c46b | 286 | int32_t list_edit_last(struct list_desc *list_desc, void *new_data); |
pmallick | 0:e8a1ba50c46b | 287 | int32_t list_read_last(struct list_desc *list_desc, void **data); |
pmallick | 0:e8a1ba50c46b | 288 | int32_t list_get_last(struct list_desc *list_desc, void **data); |
pmallick | 0:e8a1ba50c46b | 289 | /** @}*/ |
pmallick | 0:e8a1ba50c46b | 290 | |
pmallick | 0:e8a1ba50c46b | 291 | /** |
pmallick | 0:e8a1ba50c46b | 292 | * @name Operations by index |
pmallick | 0:e8a1ba50c46b | 293 | * These functions use an index to identify the element in the list. |
pmallick | 0:e8a1ba50c46b | 294 | * @{ |
pmallick | 0:e8a1ba50c46b | 295 | */ |
pmallick | 0:e8a1ba50c46b | 296 | int32_t list_add_idx(struct list_desc *list_desc, void *data, uint32_t idx); |
pmallick | 0:e8a1ba50c46b | 297 | int32_t list_edit_idx(struct list_desc *list_desc, void *new_data, |
pmallick | 0:e8a1ba50c46b | 298 | uint32_t idx); |
pmallick | 0:e8a1ba50c46b | 299 | int32_t list_read_idx(struct list_desc *list_desc, void **data, uint32_t idx); |
pmallick | 0:e8a1ba50c46b | 300 | int32_t list_get_idx(struct list_desc *list_desc, void **data, uint32_t idx); |
pmallick | 0:e8a1ba50c46b | 301 | /** @}*/ |
pmallick | 0:e8a1ba50c46b | 302 | |
pmallick | 0:e8a1ba50c46b | 303 | /** |
pmallick | 0:e8a1ba50c46b | 304 | * @name Operations by comparation |
pmallick | 0:e8a1ba50c46b | 305 | * These functions use the specified \ref f_cmp at \ref list_init to identify |
pmallick | 0:e8a1ba50c46b | 306 | * the element this will operate on. |
pmallick | 0:e8a1ba50c46b | 307 | * @{ |
pmallick | 0:e8a1ba50c46b | 308 | */ |
pmallick | 0:e8a1ba50c46b | 309 | int32_t list_add_find(struct list_desc *list_desc, void *data); |
pmallick | 0:e8a1ba50c46b | 310 | int32_t list_edit_find(struct list_desc *list_desc, void *new_data, |
pmallick | 0:e8a1ba50c46b | 311 | void *cmp_data); |
pmallick | 0:e8a1ba50c46b | 312 | int32_t list_read_find(struct list_desc *list_desc, void **data, |
pmallick | 0:e8a1ba50c46b | 313 | void *cmp_data); |
pmallick | 0:e8a1ba50c46b | 314 | int32_t list_get_find(struct list_desc *list_desc, void **data, void *cmp_data); |
pmallick | 0:e8a1ba50c46b | 315 | /** @}*/ |
pmallick | 0:e8a1ba50c46b | 316 | |
pmallick | 0:e8a1ba50c46b | 317 | #endif //LIST_H |