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

converting std::array<T,N> to std::vector<T> #11

Closed
muzammil360 opened this issue Mar 2, 2019 · 1 comment
Closed

converting std::array<T,N> to std::vector<T> #11

muzammil360 opened this issue Mar 2, 2019 · 1 comment
Assignees

Comments

@muzammil360
Copy link

@genbattle, don't you think it would be a better idea if std::vector<T> is used instead of std::array<T,N>. This way one can have a more dynamic design.

I understand std::array is probably a bit faster than std::vector but perhaps not too much.

I have changed std::array<T,N> to std::vector<T> in my code because I needed it post-compilation based on dataset.

Are you aware of any significant speed drops?

@genbattle genbattle self-assigned this Mar 3, 2019
@genbattle
Copy link
Owner

I've already had this discussion in #8. The synopsis is that a std::vector<std::vector<T>> is less efficient because of extra indirection and allocations, and it also means your rows might be of differing lengths, there's nothing to enforce consistent lengths at compile time with vector.

I have been considering creating a N-dimensional array class specifically for this library to solve this problem and provide more runtime flexibility. Another solution would be using a single std::vector<T> instead of std::vector<std::array<T,N>> and defining a separate parameter for stride (row length).

I'll implement an N-dimensional array class when I have time, but I won't be changing the code to use std::vector<std::vector<T>> in the meantime.

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