is there a difference between:
mvt_act_idx = openCloseList.size()-1;
openCloseList[mvt_act_idx].A += a;
and
openCloseList.back().A += a;
Besides readability?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No useful difference.
Using
back()directly might be fractionally more efficient, but I doubt it. You could have a look at the generated assembler if you felt really keen. Might make the difference of an instruction or two, depending on how clever your compiler is.I do note that the former way which uses only
size()and[]would be a lot more familiar to people who understand arrays or use similar contructs in any other language;back()is a bit more C++ specific (though it is hardly a cryptic idiom).