Which is the fastest? A boost::multi_array
or a std::vector
?
I will have (not constant) 17.179.869 elements stored in 3 dimensions which will need to be accessed inside a for
loop very rapidly and very often. What would be the most performing? An std::vector
or a boost::multi_array
?
(I don't expect it to be done within a second, but I would like to have it as efficient as possible because a nanosecond difference can save a lot of time.)
Best advice is to benchmark it by yourself.
In any case, since you seem to have constant size there are other solutions:
int data[X][Y][Z]
)X*W*H + Y*W + Z
, can be handy in some situationsstd::array
, which is basically a C++ array with some synctactic sugar taken from STL collectionsstd::vector
, which I guess is the first solution that can be triedboost::multi_array
, which is meant to support N dimensional arrays so it can be overkill for your purpose but probably has a better locality of data compared to a vector.