[Insight-users] Iterators and their directions

Brady McCary brady.mccary+ITK at gmail.com
Thu Mar 12 20:45:46 EDT 2009


insight-users,

I would like to have an iterator that has more than one increment
direction. E.g., in 2D:

double A[M][N];

// Populate A

for(unsigned int i = 0; i < M; i++)
for(unsigned int j = 0; j < N; j++)
{
    // Do something with the neighborhood of A[i][j]
}

for(unsigned int i = 0; i < M; i++)
for(unsigned int j = N-1; j >= 0; j--)
{
    // Do something with the neighborhood of A[i][j]
}

for(unsigned int i = M-1; i >= 0; i--)
for(unsigned int j = 0; j < N; j++)
{
    // Do something with the neighborhood of A[i][j]
}

for(unsigned int i = M-1; i >= 0; i--)
for(unsigned int j = N-1; j >= 0; j--)
{
    // Do something with the neighborhood of A[i][j]
}

In an N dimensional array there will be 2^N iteration patterns. Is
there such an iterator, or do I need to write my own?

Brady


More information about the Insight-users mailing list