Didn't mean to hijack Yumtard's thread, moved to it's own.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
Looks good, looks good. Moving the release/copy code to private funcs is a good move to eliminate code duplication (I didn't bother to do that in the solution video).
You should remove the destructor altogether and see what happens
That's cool, it shows the address of the unreleased Stack::Elem pointers and their data members {int,Elem*}.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
While I thought it clever to use recursion on the Copy function, I wouldn't know how to avoid stack overflows.
The test I failed first was the copy ( test 5 I think ). This was really the reason I called you evil. The reason I failed it was because of the order of stacks. The first time I copied, of course it was in reverse order. I tried cheating by looking through Yumtard's code, but got confused by his implementation.
When I thought about it some, you need to start at the bottom, but this is a singly linked list so you don't have access to the parent/previous element. The easiest way I could think of to go in reverse was to have the compiler unwind the stack through recursion. These are two things (recursion and linked lists) I've always passed over because I didn't understand the implementations I've seen. The code I've looked through from random places always seemed to complicated.
Thanks for the challenge, it was fun.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
Yeah, I didn't really take stack overflows into consideration for this exercise, but it would be a real concern if you were actually building a general-purpose container.
Also, nice custom iterators. I love custom iterators.
I perused the STL list file last night and found out that it's a doubly linked list; I did not know that.
I wish I could figure out how to make iterators that work with ranged for loops and other algorithms. Was trying to make a STL compatible 2D buffer and some similar algorithms to the STL; an example algorithm would be
As far as custom iterators and algorithm interaction goes, they seem fairly accepting; you can use raw pointers as the In and Out iterators. I wasn't able to use a range based for loop with the custom iterator class that I've tried in the past. I'll try again and see if I can get some info posted. I guess, if I remember right, had something to do with me not using the iterator traits, but it's been awhile.
You know, I'm not sure why I don't post here more often when I'm actually needing help.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com