mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
AK: Add IntrusiveList::take_last()
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user