View Single Post
Old 10-21-2006, 02:20 AM   #2 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 598
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
I think you made it a bit too complicated. The only case you have to handle explicitly is adding a node to the end. A simple while loop should take care of the rest.
Code:
while( plnCurr->sWord < newWord ){
    if( plnCurr->plnNext = NULL ){ //handle case of last node
         break;
    }
    plnCurr = plnCurr->plnNext;
}
DListNode* plnNew = new DListNode(rsNewData);
plnNew->plnPrev = plnCurr;
plnNew->plnNext = plnCurr->next;
plnCurr->plnNext = plnNew;
EDIT:Arg, I was off by one!
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote