Library in C++ STL?

C++Server Side ProgrammingProgramming

The C++ STL (Standard Template Library) is a powerful set of C++ template classes to provide general-purpose classes and functions with templates that implement many popular and commonly used algorithms and data structures like vectors, lists, queues, and stacks.

It is a library of container classes, algorithms, and iterators. It is a generalized library and so, its components are parameterized. Working knowledge of template classes is a prerequisite for working with STL.

Templates are a feature of the C++ programming language that allows functions and classes to operate with generic types. This allows a function or class to work on many different data types without being rewritten for each one

C++ Standard Template Library has following three well-structured components −

1 Containers

Containers are used to manage collections of objects of a certain kind. There are several different types of containers like deque, list, vector, map, etc.

  • Sequence Containers - These containers implement data structures which can be accessed in a sequential manner.

    • vector
    • list
    • deque
    • arrays
    • forward_list
  • Container Adaptors - They provide a different interface for sequential containers.

    • queue
    • priority_queue
    • stack
  • Associative Containers - They implement sorted data structures that can be quickly searched (O(log n) complexity).

    • set
    • multiset
    • map
    • multimap
  • Unordered Associative Containers - These containers implement unordered data structures that can be quickly searched

    • unordered_set
    • unordered_multiset
    • unordered_map
    • unordered_multimap

2 Algorithms

Algorithms act on containers. They provide the means by which you will perform initialization, sorting, searching, and transforming the contents of containers.

Algorithm

  • Sorting
  • Searching
  • Important STL Algorithms
  • Useful Array algorithms
  • Partition Operations

3 Iterators

Iterators are used to step through the elements of collections of objects. These collections may be containers or subsets of containers.

raja
Published on 19-Aug-2019 09:01:51
Advertisements