Timeline for Stack implementation in C#
Current License: CC BY-SA 3.0
6 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Sep 29, 2015 at 15:09 | comment | added | David Arno | @holroy I accept that, which is why I modified the code to insert/remove from the end of the list. | |
Sep 29, 2015 at 13:23 | comment | added | CodesInChaos |
A stack is pretty much the simplest collection you can use to learn how to implement a variable size collection on top of a fixed size array. You could re-implement List<T> instead, but it includes far more irrelevant features.
|
|
Sep 29, 2015 at 13:17 | comment | added | David Arno | @CodesInChaos, 1) fair point. I did it that way as a stack adds/removes from the head, so I made the code do the same. I've updated the answer though to make it more efficient. 2) I disagree. The key to a stack is the way it pushes and pops to the head. The array implementation was just implementation noise. | |
Sep 29, 2015 at 13:14 | history | edited | David Arno | CC BY-SA 3.0 |
added 78 characters in body
|
Sep 29, 2015 at 13:09 | comment | added | CodesInChaos | 1) Why would you insert in the front? That turns nice and fast O(1) operations into slow O(n) operations and doesn't simplify the code. 2) The OP is reinventing the wheel for learning purposes, this approach eliminates pretty much all the interesting parts. | |
Sep 29, 2015 at 12:45 | history | answered | David Arno | CC BY-SA 3.0 |