-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make PooledStack Indexable and Insertable #25
Comments
@Wixred just to be clear, when indexing in to a stack, would you expect Also, if we're adding an Insert method, should there also be a RemoveAt method and an IndexOf method? Should we just go ahead and implement all of |
The thought was the index is a simple wrapper around the underlying array indexer. But you're right, where do you draw the line with this functionality. |
I'm not necessarily opposed to making the class indexable, I'm just not sure of the semantics. Internally items are stored with the most-recently-added item as the last item in the internal array, and calling Peek/Pop returns the last item (but in Stack semantics, it's the first item). So the actual implementation for the indexer would need to return the value at something like I'm a little less sanguine about the Insert method. You've got the same "what does the index value actually mean" issue, plus the "where do you draw the line" issue, and I'm not sure if the added functionality would be worth it. |
Is your feature request related to a problem? Please describe.
Although not need for my primary use cases, there are some situations where I'd find it beneficial for a Stack implementation to be indexable and insertable. Unfortunately, most implementations do not support this, therefore I have to use a List and it's Add and RemoveAt and forgo the optimizations done for Pop, Peak, and Push.
Describe the solution you'd like
Add an Indexer and implement Insert(int index, T item) for PooledStack
The text was updated successfully, but these errors were encountered: