mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-08-16 17:00:35 +03:00
AK: Add SinglyLinkedList::prepend()
This commit is contained in:
parent
a39c38840e
commit
b3e0aed91f
Notes:
sideshowbarker
2024-07-17 10:20:38 +09:00
Author: https://github.com/timschumi Commit: https://github.com/SerenityOS/serenity/commit/b3e0aed91f Pull-request: https://github.com/SerenityOS/serenity/pull/14247 Reviewed-by: https://github.com/linusg ✅
@ -160,6 +160,19 @@ public:
|
||||
m_tail = node;
|
||||
}
|
||||
|
||||
template<typename U = T>
|
||||
void prepend(U&& value)
|
||||
{
|
||||
auto* node = new Node(forward<U>(value));
|
||||
if (!m_head) {
|
||||
m_head = node;
|
||||
m_tail = node;
|
||||
return;
|
||||
}
|
||||
node->next = m_head;
|
||||
m_head = node;
|
||||
}
|
||||
|
||||
bool contains_slow(const T& value) const
|
||||
{
|
||||
return find(value) != end();
|
||||
|
Loading…
Reference in New Issue
Block a user