2 ms·
> for (size_t i = size - 1; i < size; i--) { Am I alone here feeling that this while working is anything but intuitive and is asking for trouble down the road?
by heisenbit 5y ago
> for (size_t i = size - 1; i < size; i--) {
Am I alone here feeling that this while working is anything but intuitive and is asking for trouble down the road? Just imagine having to change the countdown for whatever reason in maintenance to 1 instead of zero and you suddenly fiddle with the operator.
- throwaway744678 5y agoYou are not alone! This is completely unclear: the next guy reading your code will definitely "fix" the halting condition. I'd either handle i == 0 outside of the loop, or use something like: for (size_t j = size; j > 0; --j) { size_t i = j - 1; // etc. Or even: for (size_t j = 0; j <= size; ++j) { size_t i = size - j; // etc.