mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 14:17:36 +00:00
SinglyLinkedList: Implement find
in terms of AK::find
Problem: - The implementation of `find` is coupled to the implementation of `SinglyLinkedList`. Solution: - Decouple the implementation of `find` from the class by using a generic `find` algorithm.
This commit is contained in:
parent
853cb8af5c
commit
1b2364846f
7 changed files with 106 additions and 30 deletions
|
@ -65,7 +65,8 @@ private:
|
|||
explicit Node(U&& v)
|
||||
: value(forward<U>(v))
|
||||
{
|
||||
static_assert(IsSame<T, U>::value);
|
||||
static_assert(
|
||||
requires { T(v); }, "Conversion operator is missing.");
|
||||
}
|
||||
T value;
|
||||
Node* next { nullptr };
|
||||
|
@ -113,7 +114,8 @@ public:
|
|||
template<typename U>
|
||||
void append(U&& value)
|
||||
{
|
||||
static_assert(IsSame<T, U>::value);
|
||||
static_assert(
|
||||
requires { T(value); }, "Conversion operator is missing.");
|
||||
auto* node = new Node(forward<U>(value));
|
||||
if (!m_head) {
|
||||
ASSERT(!m_tail);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue