“Choosing Wisely !!! ” — C++ Containers and Big-Oh complexity

Why we have different data structures in programming languages? Is there a real impact in terms of time and resources consumption? Yes, there is. I will use C++ programming language as reference.

Types of containers supported by STL

Container Presents in C++

Containers and Complexity

The next tables resumes the Bih-Oh consumption for each container, thinking when we are insert a new element, access an elements, erase in front or in middle, find, …

C++ STL Containers Complexity

Table from: “ STL Container Performance

When to use? What is the best container for each scenario?

We have to take in consideration some points:

The follow flowchart cam be used as azimuth when we have to choose the wright container for write propose

Flowchart based on: “ In which scenario do I use a particular STL container ?

Rules of Thumb

Also read

Know your algorithm’s complexity

Containers and Iterators ( C++ GitHub repository Notes )

Choosing the Right Container: Sequential Containers

--

--

A Software Engineer who likes to read https://nelsonbilber.github.io/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store