The Object-Oriented way of organizing data. The struct contains individual data and then an Array of this struct is created.
struct Particle {
float x, y, z;
float velocity;
int id;
};
std::vector<Particle> particles(1000);- Pros: High spatial locality if you need to access all properties of a single particle at once (e.g., updating a specific particle’s state).
- Cons: Poor for SIMD vectorization. If you want to sum only the
xcoordinates of 1 million particles, the CPU must load the entireParticlestruct into the cache, wasting bandwidth ony,z,velocity, andid.