Hi, I'm trying to transform a double linked list into a simple linked list. For that I need to change how the functions work and I'm having trouble with Insert().

The problem is that I do not have access to pPrev pointer anymore but I still need to know where the previous node is.

So if anyone have any idea on how to do this, help would be appreciated.

Code:

ClIterator Insert(ClIterator p_position, const T& p_data)
{
if (++m_nbNode== 1)
{
m_pHead= m_pTail= new TypeNode(p_data, 0);
return ClIterator(m_pHead);
}
TypeNode* pPosition= p_position.m_pNode;
if (pPosition == 0)
{
m_pTail= new TypeNode(p_data, m_pTail, 0);
m_pTail->pPrev->pNext= m_pTail;
return ClIterator(m_pTail);
}
if (pPosition == m_pHead)
{
m_pHead= new TypeNode(p_data, 0, m_pHead);
m_pHead->pNext->pPrev= m_pHead;
return ClIterator(m_pHead);
}
TypeNode* p= new TypeNode(p_data, pPosition->pPrev, pPosition);
p->pNext->pPrev= p->pPrev->pNext= p;
return ClIterator(p);
}