瀏覽代碼

feat(list): impl. find()

greatbridf 2 年之前
父節點
當前提交
f1116ddf25
共有 1 個文件被更改,包括 6 次插入1 次删除
  1. 6 1
      include/types/list.hpp

+ 6 - 1
include/types/list.hpp

@@ -168,7 +168,12 @@ public:
         allocator_traits<sentry_allocator_type>::deconstruct_and_deallocate(static_cast<sentry_node_type*>(tail));
     }
 
-    // TODO: find
+    iterator_type find(const value_type& v) noexcept
+    {
+        for (iterator_type iter = begin(); iter != end(); ++iter)
+            if (*iter == v)
+                return iter;
+    }
 
     // erase the node which iter points to
     void erase(const iterator_type& iter) noexcept