Last Updated : 03 Mar, 2025
Standard Template Library (STL) provides the built-in implementation of commonly used data structures known as containers. A container is a holder object that stores a collection of other objects (its elements). They are implemented as class templates, which allows great flexibility in the data types supported.
A container manages the storage space for its elements and provides member functions for easy access to useful operations.
Types of STL ContainersSTL containers are divided into the following categories:
Sequence containers implement linear data structures in which the elements can be accessed sequentially. Following are the sequence containers in C++ STL:
Container Name
Description
Container that wraps over fixed size static array.
Automatically resizable dynamic array.
Dynamic array of fixed-size arrays that allows fast insertions and deletions at both ends.
Implementation of Doubly Linked List data structure.
Implementation of Singly Linked List data structure.
2. Associative ContainersAssociative containers store data in some sorted order. It provides fast search, insert and delete in O(log n) time by using balanced trees like Red Black Trees.
Container Name
Description
Collection of unique elements sorted on the basis of their values.
Collection of key-value pairs sorted on the basis of the keys where no two pairs have same keys.
Collection of elements sorted on the basis of their values but allows multiple copies of values.
Collection of key-value pairs sorted on the basis of the keys where multiple pairs can have same keys.
3. Unordered Associative ContainersUnordered associative containers implement unsorted hashed data structures that can be quickly searched (O(1) amortized, O(n) worst-case complexity).
Container Name
Description
Collection of unique elements hashed by their values.
Collection of key-value pairs that are hashed by their keys where no two pairs have same keys.
Collection of elements hashed by their values and allows multiple copies of values.
Collection of key-value pairs that are hashed by their keys where multiple pairs can have same keys.
4. Container AdaptersContainer adapters provide a different interface for other containers. They adapt the behavior of underlying containers to fit specific use cases.
Container Name
Description
Adapts a container to provide stack (LIFO) data structure.
Adapts a container to provide queue (FIFO) data structure.
Adapts a container to provide heap data structure.
To master C++ Standard Template Library (STL) in the most efficient and effective way, do check out this C++ STL Online Course by GeeksforGeeks. The course covers the basics of C++ and in-depth explanations to all C++ STL containers, iterators, etc along with video explanations of a few problems. Also, you'll learn to use STL inbuilt classes and functions in order to implement some of the complex data structures and perform operations on them conveniently.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4