What is a strided array?

Thomson picture Thomson · Aug 4, 2011 · Viewed 10.8k times · Source

There is also a counterpart which is called density array. What does this mean? I have done some search, but didn't get accurate information.

Answer

unkulunkulu picture unkulunkulu · Aug 4, 2011

Say you have a structure

struct SomeStruct {
    int someField;
    int someUselessField;
    int anotherUselessField;
};

and an array

struct SomeStruct array[10];

Then if you look at all the someFields in this array, they can be considered an array on their own, but they're not occupying consequent memory cells, so this array is strided. A stride here is sizeof(SomeStruct), i.e. the distance between two consequent elements of the strided array.

A sparse array mentioned here is a more general concept and actually a different one: a strided array doesn't contain zeroes in skipped memory cells, they're just not the part of the array.

Strided array is a generalization of usual (dense) arrays when stride != sizeof(element).