Skip to content

[slot_map] partition and underlying_swap #131

@p-groarke

Description

@p-groarke

When using slot_map for components and such, one would usually implement a disable feature. This is done using a pivot, and swapping disabled elements to the end of your contiguous container. Iterating the "enabled" data will thus be contiguous.

I don't think the standard would ever accept a container with this kind of state. So a way to enable this should be provided. From my uses so far, I think a simple id_swap(Key old, Key new) would enable a lot of needed flexibility.

For disabling components, one could create 2 slot_maps, enabled and disabled, and move objects between the 2. The only problem then is users will have copies of the original id. Adding id_swap lets you move into a disabled slot_map, swap the id to the old one, never invalidating user owned ids.

There are other uses for id_swap. When using RAII to keep user ids valid, the copy constructor would need such a thing.

Ultimately, you want to keep iterators valid when moving/swapping/deleting objects. id_swap is just an idea, there may be better ways.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions