On 10/15/2016 03:14 AM, Michael Marcin wrote: [snip]
Arrays of Structures is the normal programming model.
Let's take a toy example, say I'm looking at some census data and have a structure that looks like:
struct citizen_t { string first_name; string last_name; int salary; int age; };
Then the Array of Structures container would be: vector
aos_citizens; The Structure of Arrays version of the same data would look like:
struct soa_citizens_t { vector<string> first_names; vector<string> last_names; vector<int> salary; vector<int> age; };
soa_citizens_t soa_citizens;
[snip]
// Structures of Arrays int avg = 0; int t = 1; for ( int salary : soa_citizens.salary ) { avg += (salary - avg) / t; ++t; }
To generalize, what about:
template