The situation I have is like
// radius is an int[]
for ( int i = 0; i < radius.length; ++i )
{
for ( int j = 0; j < radius.length; ++j )
{
// do some stuff
}
}
Except I actually want j
to go through the range 0
-radius.length
, but skip over i
:
{0,1,..., i-1, i+1, ..., radius.length}
I'm wondering if there's a way to do this that is compact, elegant, efficient, readable, and maybe even correct.
How I planned to do it was
for ( int i = 0; i < radius.length; ++i )
{
for ( int j = 0; j < radius.length; )
{
// do some stuff
j += j != i ? 1 : 2;
}
}