Skip to content

Consder adding Deque.makeContiguous() #4

@lilyball

Description

@lilyball

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions