[Project Combat] Introduction to STL (Standard Templete Library) of C++ Standard Library

1. What is STL?

STL (Standard Templete Library)
STL is a data structure and algorithm library implemented by templates in the C++ field. It has been included in the C++ standard library. STL is a part
of the C++ standard library.
STL provides a series of general data structures and algorithms. Including containers, algorithms, function templates, etc.
STL is a standard template library used to manage a collection of certain types of objects

Two, the goal of STL

The goal of STL is to provide an efficient, portable, and modular programming method, so that programmers can use and combine various data structures and algorithms more easily, so as to develop high-quality software more efficiently.

The design concept of STL is modularization, portability and efficiency. Its design goal is to improve the readability and portability of the code as much as possible under the premise of ensuring high efficiency.

3. What does STL contain?

The main components of STL include: container + algorithm + function template

3.1 Container

STL provides a series of standard containers, which can be vector, list, stack, queue, deque, set, map, multiset, multimap, array, linked list, tree, hash map, etc.

These containers have efficient memory management functions. The containers are used to process the elements in the collection. They can quickly perform operations such as inserting, deleting, modifying, searching, sorting, and using elements for different purposes. These container structures not only have more powerful functions, but also have higher security.

3.2 Algorithms

STL provides a series of standard algorithms, such as find, lower_bound, upper_bound, equal_to, push_front, push_back, pop_front, pop_back, etc. These algorithms can effectively solve common problems in various data structures.

3.3 Function Templates

A series of function templates are provided, such as transform, front, back, size, empty, max, min, etc. These function templates can make it easier for programmers to use and combine various data structures and algorithms. The design concept of STL is modularization, portability and efficiency. Therefore, many data structures and algorithms in STL are in the form of templates and function templates, making them more flexible to adapt to various scenarios and needs.

3.4 Generalized iterators

In addition to the data structure of STL, STL also contains generalized iterators, and various algorithms that operate on iterators.
These applications that do not require too much performance but do not want to implement the algorithm from the bottom layer are still very tempting.

With the help of iterators, we only need to write the algorithm once and apply it to any container, because the iterators of all containers provide a consistent interface.

Guess you like

Origin blog.csdn.net/wstever/article/details/132133441