EDITOR’S PICK

C++ STL UNDER THE HOOD

Not knowing what you are using can be dangerous!

--

Internal Implementation of C++ STL — Standard Template Library.

Who can be a better best friend in competitive programming than STL? me?

But Priyansh… Why do all this?

— Well, This can come in handy during interviews, (or, good to know what you are using at least).

Couldn’t find a more direct and complete list over the internet so made one myself.

So let's jump right in!

[STL] | [INTERNAL IMPLEMENTATION DATA STRUCTURE]

meaning —
for e.g —
Set STL, which we use blindly everywhere, has its internal implementation(what it’s coded with) using a Red-Black Tree.

  1. stackArray, List, Deque.
  2. vectorDynamic Array
  3. listDynamic Array and Doubly Linked List
  4. pairdefined in <utility> header file
  5. queueArray, List
  6. deque(double-ended-queue) — Dynamic Array
  7. priority_queueHeap

more

  1. setRed Black Tree
  2. multisetBinary Search Tree
  3. unordered setHash Table

and more…

  1. mapRed Black Tree (Self-Balancing BST)
  2. multimapRed Black Tree
  3. unordered map(4x faster than the map) — Hash Table

sort() — uses IntroSort(a hybrid of Quicksort, Heapsort, and Insertion Sort), Faster than qsort().

I’d love to hear your thoughts about this, so feel free to reach out to me on LinkedIn or Twitter or respond in the comments below, that’d be great.

— If this article helped you in any way, consider sharing it with 2 friends you care about.

Till then stay alive.

references —

leetcode.com

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Priyansh Khodiyar
Priyansh Khodiyar

Written by Priyansh Khodiyar

I write highly researched technical articles on things I daily learn, sometimes code, and interview people. My DevOps publication - unyaml.com

Responses (5)

Write a response