Reputation: 497
I have being seeing some weird codes of late. And i could not understand significance of their use.
a if(m==c)m=c;
does not make any sense until it is seen in a library such as fastutil and jhighlight. I have googled a lot on the subject but to my surprise it seems to be Java specification which is not so documented - maybe due to deprecation or such. I will be grateful if someone would elaborate.
int comparison;
while ( b <= c && ( ( comparison = comp.compare( b, m ) ) <= 0 ) ) {
if ( comparison == 0 ) {
if ( a == m ) m = b; // moving target; DELTA to JDK !!!
else if ( b == m ) m = a; // moving target; DELTA to JDK !!!
swapper.swap( a++, b );
}
b++;
}
while ( c >= b && ( ( comparison = comp.compare( c, m ) ) >= 0 ) ) {
if ( comparison == 0 ) {
if ( c == m ) m = d; // moving target; DELTA to JDK !!!
else if ( d == m ) m = c; // moving target; DELTA to JDK !!!
swapper.swap( c, d-- );
}
c--;
}
if ( b > c ) break;
if ( b == m ) m = d; // moving target; DELTA to JDK !!!
else if ( c == m ) m = c; // moving target; DELTA to JDK !!!
swapper.swap( b++, c-- );
}
Upvotes: 3
Views: 82