summaryrefslogtreecommitdiff
path: root/include/alist.h
AgeCommit message (Collapse)Author
2024-11-03alist: Add a way to efficiently filter an alistSimon Glass
Unlike linked lists, it is inefficient to remove items from an alist, particularly if it is large. If most items need to be removed, then the time-complexity approaches O(n2). Provide a way to do this efficiently, by working through the alist once and copying elements down. Signed-off-by: Simon Glass <[email protected]>
2024-11-03alist: Add a function to empty the listSimon Glass
Sometimes it is useful to empty the list without de-allocating any of the memory used, e.g. when the list will be re-populated immediately afterwards. Add a new function for this. Signed-off-by: Simon Glass <[email protected]>
2024-11-03alist: Add for-loop helpersSimon Glass
Add some macros which permit easy iteration through an alist, similar to those provided by the 'list' implementation. Signed-off-by: Simon Glass <[email protected]>
2024-11-03alist: Add a way to get the next elementSimon Glass
Add a new function which returns the next element after the one provided, if it exists in the list. Signed-off-by: Simon Glass <[email protected]>
2024-11-03alist: Expand the comment for alist_get()Simon Glass
Add a better description for this macro. Signed-off-by: Simon Glass <[email protected]>
2024-11-03alist: Add a comment for alist_init_struct()Simon Glass
Comment this macro so that it is clear how to use it. Signed-off-by: Simon Glass <[email protected]>
2024-11-03alist: Mention the error condition in alist_add_placeholder()Simon Glass
Update the function comment to note that this function can return NULL if it runs out of memory. Signed-off-by: Simon Glass <[email protected]>
2024-09-03alist: add a helper to check if the list is fullSughosh Ganu
Add a helper function to check if the alist is full. This can then be used to extend the alist. Signed-off-by: Sughosh Ganu <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2024-08-07alist: Add support for an allocated pointer listSimon Glass
In various places it is useful to have an array of structures, but allow it to grow. In some cases we work around it by setting maximum number of entries, using a Kconfig option. In other places we use a linked list, which does not provide for random access and can complicate the code. Introduce a new data structure, which is a variable-sized list of structs each of the same, pre-set size. It provides O(1) access and is reasonably efficient at expanding linearly, since it doubles in size when it runs out of space. Signed-off-by: Simon Glass <[email protected]>