1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 17:18:11 +00:00

AK: Add IntrusiveList::take_last()

This commit is contained in:
Andreas Kling 2020-11-24 16:37:55 +01:00
parent 3e3a72f2a2
commit c33d71c5ff
2 changed files with 25 additions and 13 deletions

View file

@ -56,6 +56,7 @@ public:
T* last() const;
T* take_first();
T* take_last();
class Iterator {
public:
@ -233,6 +234,16 @@ inline T* IntrusiveList<T, member>::take_first()
return nullptr;
}
template<class T, IntrusiveListNode T::*member>
inline T* IntrusiveList<T, member>::take_last()
{
if (auto* ptr = last()) {
remove(*ptr);
return ptr;
}
return nullptr;
}
template<class T, IntrusiveListNode T::*member>
inline T* IntrusiveList<T, member>::last() const
{