Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I am trying to write a remove() fun

Status
Not open for further replies.
Feb 16, 2003
2
0
0
US
I am trying to write a remove() function for a Doubly LinkedList. I am using c++ in .NET, and wondering if anyone has some quick suggestions how to do it. Thanks
 
First suggestion: don't write a doubly linked list unless it's for educational purposes. Use std::list instead. Reinventing the wheel is bad.

Next Suggestion: if you must write your own, save a pointer to the doomed node, make doomed's left's right point to doomed's right, and make doomed's right's left point to doomed's left. Delete doomed. Special case for first and last items and you're done.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top