1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 12:08:14 +00:00

AK: Add IntrusiveList::take_first()

This commit is contained in:
Andreas Kling 2019-12-22 12:23:30 +01:00
parent 4b8851bd01
commit 96cfddb3ac

View file

@ -27,6 +27,8 @@ public:
T* first() const;
T* last() const;
T* take_first();
class Iterator {
public:
Iterator();
@ -193,6 +195,16 @@ inline T* IntrusiveList<T, member>::first() const
return m_storage.m_first ? node_to_value(*m_storage.m_first) : nullptr;
}
template<class T, IntrusiveListNode T::*member>
inline T* IntrusiveList<T, member>::take_first()
{
if (auto* ptr = first()) {
remove(*ptr);
return ptr;
}
return nullptr;
}
template<class T, IntrusiveListNode T::*member>
inline T* IntrusiveList<T, member>::last() const
{