summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
Diffstat (limited to 'AK')
-rw-r--r--AK/SinglyLinkedList.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/AK/SinglyLinkedList.h b/AK/SinglyLinkedList.h
index 284aa3c3d4..79babf10e5 100644
--- a/AK/SinglyLinkedList.h
+++ b/AK/SinglyLinkedList.h
@@ -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();