Summary of C++STL Common Operations

Summary of C++STL Common Operations

1. Introduction to STL:

STL (Standard Template Library), standard template library.

STL code is mainly divided into algorithm (algorithm), container (container), iterator (iterator); in addition, there are functor, adapter, and space configurator.

In STL, vector encapsulates arrays, string encapsulates strings, map and set encapsulate balanced binary trees, stack encapsulates stacks, queue encapsulates queues, lower_bound and upper_bound encapsulates binary search...

In the process of programming, we often use related content, and coding by ourselves is very time-consuming and laborious. It will be much more convenient to use the STL library that our predecessors have done.

advantage:
  • STL is part of C++, so no additional installation is required, it is built into your compiler.
  • An important feature of STL is the separation of data and operations. Data is managed by container categories, and operations are defined by customizable algorithms. The iterator acts as a "glue" between the two so that the algorithm can interact with the container
  • Programmers do not need to think about the specific implementation process of STL, as long as they can use STL proficiently. So they can focus on other aspects of program development.
  • STL has the advantages of high reusability, high performance, high portability, and cross-platform.
    • High reusability: Almost all code in STL is implemented in the form of template classes and template functions, which provides better code reuse opportunities than traditional libraries composed of functions and classes.
    • High performance: For example, map can efficiently find the specified record from 100,000 records, because map is implemented by a variant of the red-black tree.
    • High portability: For example, modules written in STL on Project A can be directly transplanted to Project B.

2. Common content:

vector:https://blog.csdn.net/qq_45985728/article/details/112598270

string:https://blog.csdn.net/qq_45985728/article/details/112601755

stack:https://blog.csdn.net/qq_45985728/article/details/112616443

queue:https://blog.csdn.net/qq_45985728/article/details/112624175

pair:https://blog.csdn.net/qq_45985728/article/details/112666687

map:https://blog.csdn.net/qq_45985728/article/details/112687378

multimap:https://blog.csdn.net/qq_45985728/article/details/112789885

set:https://blog.csdn.net/qq_45985728/article/details/112791689

multiset:https://blog.csdn.net/qq_45985728/article/details/112794484

priority_queue:https://blog.csdn.net/qq_45985728/article/details/113044949

sort:https://blog.csdn.net/qq_45985728/article/details/113048880

lower_bound、upper_bound:https://blog.csdn.net/qq_45985728/article/details/113054130

unordered_map:https://blog.csdn.net/qq_45985728/article/details/113663410

Guess you like

Origin blog.csdn.net/qq_45985728/article/details/113056198
Recommended