|
-
May 17th, 2015, 12:24 AM
#3
Re: How to get the address of 1st node in <list>
 Originally Posted by tush123
Reversing Linklist using Stack.
The STL containers don't give you access to implementation detail like say internal pointers.
What you could do is push the elements on stack, clear the list, and then rebuild it with the elements in reverse order.
A more efficient way would be to use one forward iterator and one reverse iterator to swap the list elements pairwise until the iterators meet in the middle.
Also note that std::list has a reverse function already.
Last edited by razzle; May 17th, 2015 at 01:37 AM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|