| Age | Commit message (Collapse) | Author |
|
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]>
|
|
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]>
|
|
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]>
|
|
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]>
|
|
Add a better description for this macro.
Signed-off-by: Simon Glass <[email protected]>
|
|
Comment this macro so that it is clear how to use it.
Signed-off-by: Simon Glass <[email protected]>
|
|
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]>
|
|
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]>
|
|
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]>
|