mirror of
https://github.com/SerenityOS/serenity
synced 2024-07-22 02:26:11 +00:00
AK: Add SinglyLinkedList::prepend()
This commit is contained in:
parent
a39c38840e
commit
b3e0aed91f
|
@ -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 a new issue