Closed muzammil360 closed 5 years ago
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.
@genbattle, don't you think it would be a better idea if
std::vector<T>
is used instead ofstd::array<T,N>
. This way one can have a more dynamic design.I understand
std::array
is probably a bit faster thanstd::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?