Different STL containers like vector, stack, set, queue, etc support different access methods on them.
If you are coding for example in Notepad++ or vim, you have to continuously refer to the documentation to see what all methods are available, atleast I have to.
Is there some good way of remembering which container supports which methods??
An STL container is a collection of objects of the same type (the elements). Container owns the elements. Creation and destruction is controlled by the container.
In C++, there are generally 3 kinds of STL containers: Sequential Containers. Associative Containers. Unordered Associative Containers.
A container is an object that stores a collection of elements (i.e. other objects). Each of these containers manages the storage space for their elements and provides access to each element through iterators and/or member functions.
C can't have an "exact equivalent" of STL because C doesn't have templates or classes.
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
.
Use them enough so that you remember the methods of each.
If your memory keeps failing you, try keeping a reference of them all up in another window. If you have more than one monitor, it's really handy to have stuff like this on a second monitor (for documentation of any kind).
Alternatively I highly recommend a real coding IDE with intellisense! Notepad++ is probably too simple for being productive in C++.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With