Implement LinkedList::visit()

Change-Id: Ibd9d133dddf1f2e6e65660e3cd2dacafcc0c84d9
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>