Skip to content
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

Add in reserve_exact and truncate #9

Open
CosmicHorrorDev opened this issue Aug 2, 2020 · 2 comments
Open

Add in reserve_exact and truncate #9

CosmicHorrorDev opened this issue Aug 2, 2020 · 2 comments

Comments

@CosmicHorrorDev
Copy link

Adding in reserve_exact and truncate would allow the circular queue to be resized. This behavior was brought up in cjbassi/ytop#96 where circular-queue would be a good choice: however, resizing would be required and the most ergonimic way I can find to do this would be to create a new circular queue and copying over all the old elements.

Would you be open to reserve_exact and truncate being added?

@YaLTeR
Copy link
Owner

YaLTeR commented Aug 3, 2020

So, the way CircularQueue works does indeed mean that the simplest (the only safe?) method of resizing in the general case is creating a new vector and moving the elements over. I would be open to introducing those methods into CircularQueue.

Should it be reserve or reserve_exact or maybe some other name? On a Vec, both of them say the resulting capacity will actually be >= the requested capacity...

@CosmicHorrorDev
Copy link
Author

I thought the difference between reserve and reserve_exact was that reserve_exact would only reserve enough for the additional amount, but I see that that is not the case. I think that reserve should be just fine instead of reserve_exact and makes it easy for people to find coming from Vec or other collections to understand the purpose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants