mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:17:44 +00:00
AK: Add IntrusiveList::take_first()
This commit is contained in:
parent
4b8851bd01
commit
96cfddb3ac
1 changed files with 12 additions and 0 deletions
|
@ -27,6 +27,8 @@ public:
|
||||||
T* first() const;
|
T* first() const;
|
||||||
T* last() const;
|
T* last() const;
|
||||||
|
|
||||||
|
T* take_first();
|
||||||
|
|
||||||
class Iterator {
|
class Iterator {
|
||||||
public:
|
public:
|
||||||
Iterator();
|
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;
|
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>
|
template<class T, IntrusiveListNode T::*member>
|
||||||
inline T* IntrusiveList<T, member>::last() const
|
inline T* IntrusiveList<T, member>::last() const
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue