Hello everybody! Exscusme buy my English )))
I have this problem: I must iterate items in STL list with posible editing items: remove, add, edit. This is my approach:
void MoveOnNewPlace(Tree& parent, Tree& child)
{
Tree *temp=&parent;
while(temp->GetParent()!=temp && temp->GetItem().GetChar()=='(')
temp=temp->GetParent();
if(*temp==parent) return;
Tree newTr(child);
newTr.SetParent(*temp);
temp->GetSubNodes()->push_back(newTr); //(Tree(child,temp));
parent.GetSubNodes()->remove(child);
}
list<Tree>::_Nodeptr ptr=nodes->_Myhead->_Next;
unsigned int i=0;
while(i++<nodes->size() && ptr!=0)
{
Prepair(ptr->_Myval);
if(ptr->_Myval.GetItem().GetChar()=='[')
MoveOnNewPlace(t,ptr->_Myval);
ptr=ptr->_Next;
}
Could someone tell me how I can do it in other way without explicity using _Myhead, _Myhead and so on. Thanks!