alist: Add a way to efficiently filter an alist

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 <sjg@chromium.org>
diff --git a/lib/alist.c b/lib/alist.c
index 32cd45b..4ce651f 100644
--- a/lib/alist.c
+++ b/lib/alist.c
@@ -123,6 +123,14 @@
 	return index;
 }
 
+void alist_update_end(struct alist *lst, const void *ptr)
+{
+	int index;
+
+	index = alist_calc_index(lst, ptr);
+	lst->count = index == -1 ? 0 : index;
+}
+
 bool alist_chk_ptr(const struct alist *lst, const void *ptr)
 {
 	int index = alist_calc_index(lst, ptr);