Question: Need help with functions / / inserts an element at the end of the list / / [ 2 ] void push _ back (

Need help with functions
// inserts an element at the end of the list
//[2]
void
push_back (const value_type& value)
{
// Hint: could be one-line call to insert()
ListNode* node = new ListNode(value, &m_header, m_header.prev);
m_header.prev->next = node;
m_header.prev = node;
++m_size;
}
// inserts an element at the front of the list
//[2]
void
push_front (const value_type& value)
{
// Hint: could be one-line call to insert()
ListNode* node = new ListNode(value, m_header.next, &m_header);
m_header.next->prev = node;
m_header.next = node;
++m_size;
}
// erase element pointed to by "pos" -- returns iterator to next element
//[4]
iterator
erase (iterator pos)
{
// Hint: call unhook on the correct ListNode and delete it
ListNode* node = pos.m_node;
++pos;
node->unhook();
delete node;
--m_size;
return pos;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!