Search code examples
c++stlmethodscontainers

How to remember the different methods used in C++ STL containers instead of checking the documentation again and again?


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?


Solution

  • 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.