Different STL containers like vector
, stack
, set
, queue
, etc support different access methods.
If you are coding in say Notepad++ or vim, you have to continuously refer to the documentation to see what all methods are available, at-least I have to.
Is there some good way of remembering which container supports which methods?
The names of the methods aren't different for the sake of being different. It helps in remembering which containers have which methods, to understand the meaning of the name. push_back
for example is nonsensical in relation to sets. insert
doesn't make any sense when talking about stacks (of course stacks don't have a front or a back either, so it doesn't support push_back
, just push
). For a vector, both have a well-defined meaning, so vector supports both insert
and push_back
.