Function gamer::Vect2Index

Function Documentation

inline std::size_t gamer::Vect2Index(const std::size_t i, const std::size_t j, const std::size_t k, const Vector3szt &dim)

Convert 3D array indices to the index of a flat array.

As a convention use the following loop structure to optimize cache efficiency:

for (int k;...; k++){
  for (int j;...; j++){
    for (int i;...; i++){
In short, index i should occupy the inner most scope followed by j then k.

  • i[in] Value of the first index

  • j[in] Value of the second index

  • k[in] Value of the third index

  • dim[in] Dimensions of the 3D array


Index of flat array corresponding to indices in 3D array.