Thinking in C + +: STL algorithm

Thinking in C + + > STL algorithm summary notes. STL algorithm directory 0. Algorithm overview fill(), assign value to each element of [first, last].fill_n(), n elements starting from first are assigned value.generate(), use the generator to generate a value for each element of [first, last].generate_n() generates a value for the n el ...

Posted by Gayner on Tue, 25 Jan 2022 07:28:40 +0100

Template specialization and type extraction

1, Purpose and significance of type extraction 1. Type extraction is the purpose (1) A typical application is to distinguish whether T is a source generated type POD or a user-defined type in the template function (2)POD,Plain Old Data, is simply understood as the basic types inherited from C by C + +, such as int, double, etc (3) The e ...

Posted by BoltZ on Thu, 20 Jan 2022 20:22:23 +0100

Summary of common algorithms for C + + super detailed STL

STL common algorithms: Write at the beginning: sort out some algorithms commonly used in stl, involving comparison, exchange, search, traversal, replication, modification, etc. It's worth collecting!! summary: The algorithm is mainly composed of header files < algorithm > < functional > < numeric >.< algorithm > ...

Posted by nmal on Wed, 19 Jan 2022 21:40:54 +0100

[C + + from bronze to king] Part 10: simulation and implementation of vector class of STL

Catalogue of series articles preface 1, Depth analysis and Simulation of vector 1. Simulation implementation of the core interface of vector namespace yyw { template<class T> class vector { public: typedef T* iterator; typedef const T* const_iterator; public: iterator begin() { return _start; } it ...

Posted by bbauder on Wed, 19 Jan 2022 10:46:49 +0100

[C + +] simulation implementation of string class

I Simple string class design It mainly realizes the resource management functions such as string class construction, copy construction, assignment operator overloading and destructor. 1. private members Is a string pointer in C language class string { public: private: char* _str; }; 2. Constructor We design a fully default default ...

Posted by alfoxy on Thu, 06 Jan 2022 00:29:14 +0100

Memory distribution malloc/calloc/realloc/free/new/delete, memory leak, string template, shallow copy and deep copy, and the implementation of simulated string class

Memory distribution 1, Dynamic memory management in C language: malloc/calloc/realloc and free 1.malloc: Obtain the memory space of the specified byte from the heap. The function declaration: void *malloc (int n); If the function is executed successfully, malloc returns the first address of the obtained memory space; If the function fail ...

Posted by jkatcherny on Tue, 04 Jan 2022 22:59:37 +0100

c + + common STL summary (balanced binary tree multiset)

The complexity of adding, deleting and searching data structures is limited to log(n), which is embodied in four sorting containers: multiset and Multimap in STL Multiset header file: Multimap header file: This paper deals with several container traversal methods of multiset and Multimap: only with the help of iterators multiset::iterator p; p ...

Posted by Gasolene on Tue, 04 Jan 2022 08:18:27 +0100

vector introduction and basic use

I vector introduction vector document vector is a sequence container that represents a variable size array. Like arrays, vectors use continuous storage space to store elements. This means that you can use subscripts to access the elements of a vector, which is as efficient as an array. But unlike an array, its size can be changed dynamic ...

Posted by ggkfc on Tue, 28 Dec 2021 15:30:43 +0100

C++list Simulation Implementation

The greatest advantage of hard work is that you can choose the life you want instead of being forced to let it be. 🎓 list introduction 1. List is a sequential container that can be inserted and deleted anywhere in the * * constant range O(1) * *, and the container can iterate back and forth, but the list container is not suitable for so ...

Posted by alexk1781 on Sat, 25 Dec 2021 05:04:24 +0100

Stay up late to burst the liver! C++ Core STL Container string Knowledge Points Compilation [10,000 words dry goods warning recommendation collection]

Preface Some time ago, some fans asked me, when I finished my freshman year, I didn't know how I am doing with c++? Have you got all the points you need to know? Are you getting started? I have sorted out the C++ Basic and Core Advanced Knowledge Points in the last few days. If you haven't seen them, you can see them! Stay up late to burst th ...

Posted by ntohky14 on Sat, 18 Dec 2021 20:41:38 +0100