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

Consder adding Deque.makeContiguous() #4

Open
lilyball opened this issue Nov 23, 2020 · 1 comment
Open

Consder adding Deque.makeContiguous() #4

lilyball opened this issue Nov 23, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@lilyball
Copy link
Owner

Deque can have either contiguous or noncontiguous storage depending on mutation patterns. It supports providing a pointer to its backing storage if and only if it's contiguous. It also makes certain guarantees about indices after mutation as long as it doesn't transition between contiguous and noncontiguous storage.

Right now, if I need to force a Deque to be contiguous, the only practical way to do this is to force a copy into a new Deque using something like Deque(AnySequence(deque)). Not only is this awkward, it also forces a copy even if the source was already contiguous.

To that end, we may want to add a deque.makeContiguous() method that ensures the storage is contiguous. We may also want to add optional parameters for asserting sufficient capacity before/after the contiguous storage, to allow for guarantees about indices and contiguous storage availability after appending/prepending elements.

@lilyball lilyball added the enhancement New feature or request label Nov 23, 2020
@lilyball
Copy link
Owner Author

Question: With the parameters to assertion sufficient pre/post capacity, would we want this to behave like reserveCapacity in that it can shrink the capacity if it has to reallocate? I'm inclined to say yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant