Efficient Data Structures

Context

Approach using a skeleton class (Stephen)

/*
... omitted code ...
  ... omitted code ...
  ... omitted code ...
*/


template <template <typename> typename F>
struct S {
using tuple_t = std::tuple<int, int, double, int>;
F<int> x, y;
F<double> activation;
F<int> identifier;
};

int main() {
array_wrapper<aos, S>::owner my_array_owner(4); // aos can be changed to soa
array_wrapper<aos, S>::handle my_array(my_array_owner); // aos can be changed to soa
for (int i = 0; i < 4; i++) {
auto my_element = my_array[i];
  my_element.x = i - 10;
  my_element.y = i + 50;
  my_element.activation = std::sin(static_cast<double>(i));
  my_element.identifier = i;
}
return 0;

}

 

Advantages:

 

Disdvantages:

David's variation of this approach