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

New container: chunked_vector #274

Open
HDembinski opened this issue Apr 24, 2024 · 1 comment
Open

New container: chunked_vector #274

HDembinski opened this issue Apr 24, 2024 · 1 comment

Comments

@HDembinski
Copy link

HDembinski commented Apr 24, 2024

For Boost.Histogram, I need a new type of container. I plan to implement a private version to keep histogram decoupled from Boost.Container, but I wanted to propose this type of container for Boost.Container.

The container should store chunks of homogenous types with fixed length, which is defined at runtime, not compile time.

The container is internally implemented like std::vector, memory is contiguous. The element of the container is not a single value, but a chunk of values with fixed size, which is defined at runtime when the container is created. The value type of the container should be static_vector or small_vector, while its reference types should based on boost::span.

Basically, this is a much more efficient version of std::vector<std::vector<T>> for the case when you know that the inner vector will always have same length, but you don't know this length at compile-time, so you cannot use std::vector<std::array<T, N>>.

I tentatively call this chunked_vector, but I hope you come up with a better name.

@igaztanaga
Copy link
Member

This seems like a quite specialized container, I don't feel it's general enough for Boost.Container. One option would be to add the option to dynamically specify the size of the chunk ("block", in boost::container::deque terminology). Currently the block size can be specified at compile-time, but if it could be specified at runtime, then a specialized container like yours would be easy to implement.

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

No branches or pull requests

2 participants