mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:57:35 +00:00
AK: Add SinglyLinkedList::prepend()
This commit is contained in:
parent
a39c38840e
commit
b3e0aed91f
1 changed files with 13 additions and 0 deletions
|
@ -160,6 +160,19 @@ public:
|
||||||
m_tail = node;
|
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
|
bool contains_slow(const T& value) const
|
||||||
{
|
{
|
||||||
return find(value) != end();
|
return find(value) != end();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue