c++ learning-STL common functions

Part 8-STL Common Functions

image-20221107212335851

5.1 Commonly used traversal algorithms

image-20221107212457264

5.1.1 for_each

image-20221107212525930

image-20221107212317465

image-20221107212242477

5.1.2 transform

image-20221107215048970

image-20221107220745594

image-20221107220807357

image-20221107220828183

5.2 Common search algorithms

image-20221107221448485

5.2.1 find

image-20221107221525446

5.2.2 find_if

image-20221107221929935

image-20221108150324766

image-20221108150352157

image-20221108150437739

image-20221108150459352

5.2.3 adjacent_find

image-20221108150527951

image-20221108150651513

If there is an interview question about finding adjacent repeated elements, remember to use the adjacent_find algorithm in stl

5.2.4 binary_search

image-20221108150905585

image-20221108151030986

image-20221108151118499

5.2.5 count

image-20221108151143998

5.2.6 count_if

image-20221108151534284

5.3 Commonly used sorting algorithms

image-20221108151732128

5.3.1 sort

image-20221108151806280

image-20221108152019263

More commonly used, requires proficiency

5.3.2 random_shuffle

image-20221108152103048

Summary: The random_shuffle shuffling algorithm is more suitable. Remember to add a random number seed when using it.

5.3.3 merge

image-20221108152253492

image-20221108152423950

Summary: The two containers merged by merge must be an ordered sequence

5.3.4 reverse

image-20221108152511690

5.4 Common copy and replacement algorithms

5.4.1 copy

image-20221108153950552

image-20221108154109231

5.4.2 replace

image-20221108154141202

image-20221108154303522

5.4.3 replace_if

image-20221108154332142

image-20221108154428338

5.4.4 swap

image-20221108154500535

Only elements of the same type can be exchanged

5.5 Commonly used arithmetic generation algorithms

image-20221108154624083

5.5.1 accumulate

image-20221108154649174

5.3.2 fill

image-20221108155855378

image-20221108155921015

5.6 Common set algorithms

image-20221108160016599

5.6.1 set_intersection

image-20221108204019609

image-20221108204130883

image-20221108204144308

5.6.2 set_union

image-20221108204708507

image-20221108205543288

image-20221108205558369

5.6.3 set_difference

image-20221108205729223

image-20221108214020392

image-20221108214027300

Guess you like

Origin blog.csdn.net/charles_zhang_/article/details/127759602