What is happening when we decrement the code here:
temp[--countArray[getDigit(position, input[tempIndex], radix)]]
If temp is 1 in this case: are we decrementing first so that we are assigning to 0? How immediate is this decrement? It always seems to confuse me within array brackets.
Try unpacking the brackets on different levels of indentation:
In human-readable terms, it calls
getDigit()to index intocountArray, then decrements that value and uses it to index intotemp.The decrement operator
--xis different fromx--because of what it returns. By the end of the operation,xalways ends up as one less than it was, but--xreturns the new value ofx, whilex--returns the old value ofxfrom before it was decremented. The same applies for++xandx++.