Implement LinkedList::visit()
(cherry picked from commit a4926058496c1c24c00ac07e42d45048dac7c487)
Change-Id: I59554be45c910bfe33494016595a5ade9daad230
diff --git a/linker/linked_list.h b/linker/linked_list.h
index 14fe1e5..5fbdc8f 100644
--- a/linker/linked_list.h
+++ b/linker/linked_list.h
@@ -86,10 +86,21 @@
}
template<typename F>
- void for_each(F&& action) {
+ void for_each(F action) {
+ visit([&] (T* si) {
+ action(si);
+ return true;
+ });
+ }
+
+ template<typename F>
+ bool visit(F action) {
for (LinkedListEntry<T>* e = head_; e != nullptr; e = e->next) {
- action(e->element);
+ if (!action(e->element)) {
+ return false;
+ }
}
+ return true;
}
template<typename F>