libluna: Add LinkedList::add_before() to mirror add_after()
Need this for later.
This commit is contained in:
parent
e1d5b7e7b4
commit
54ec441000
@ -108,6 +108,22 @@ template <typename T> class LinkedList
|
||||
m_count++;
|
||||
}
|
||||
|
||||
void add_before(T* base, T* ptr)
|
||||
{
|
||||
Node* const new_node = extract_node(ptr);
|
||||
Node* const base_node = extract_node(base);
|
||||
|
||||
if (m_start_node == base_node) m_start_node = new_node;
|
||||
|
||||
if (base_node->get_last()) base_node->get_last()->set_next(new_node);
|
||||
|
||||
new_node->set_last(base_node->get_last());
|
||||
base_node->set_last(new_node);
|
||||
new_node->set_next(base_node);
|
||||
|
||||
m_count++;
|
||||
}
|
||||
|
||||
T* remove(T* ptr)
|
||||
{
|
||||
Node* const node = extract_node(ptr);
|
||||
|
Loading…
Reference in New Issue
Block a user