Detailed explanation of common usage of [c + + container] priority_queue

priority_queue is also called priority queue, and its bottom layer is implemented by heap. In the priority queue, the first element must be when The highest priority in the previous queue. For example, there are the following elements in the queue, and the priority is defined: Peach(Priority 3) Pear(Priority 4) Apple(Priority 1) Then the ...

Posted by jvquach on Fri, 17 Dec 2021 00:56:31 +0100

C++STL standard library learning notes multimap

preface: In this note, I annotated most of the code. Some of my ideas and comments were marked in blue, and the key points and areas needing attention were marked in red. In this article, we mainly introduce the usage and application of multimap 1.1 usage of ultimap You need #include < Map > when using The elements in the multimap co ...

Posted by phast1 on Tue, 14 Dec 2021 13:09:52 +0100

C + + template function

1. Template function 1. Declaration and definition of template function C + + provides the concept of template programming. The so-called template is actually to establish a general function or class. The type inside the class and the formal parameter type of the function are not specified specifically, but are represented by a virtual ...

Posted by cool75 on Wed, 08 Dec 2021 12:11:43 +0100

[ten thousand words summary] detailed explanation of common algorithms in C++STL (wrong year series)

Write in front This little rookie is a sophomore who loves programming. At present, he mainly focuses on learning C + +, data structure and algorithm.I have only started learning algorithms in the last two months (who knows what I did in my freshman year). I have been tortured by algorithms (it's too difficult...). I have brushed more than ...

Posted by colossus_09 on Mon, 29 Nov 2021 15:13:03 +0100

Modern writing of C++ string

1, Modern writing implementation interface The first is the realization of modern writing method of copy construction: string_str(const string_str& st) :str(nullptr) { string_str tem(st.str); swap(this->str, tem.str); First, set this - > STR to null, then temp calls the constructor and initializes this - > STR wit ...

Posted by Syrehn on Thu, 18 Nov 2021 16:10:22 +0100

How to implement user defined iterator

home pagespecial columnloggerArticle details0How to implement user defined iteratorhedzr Released today at 19:15 Implement your own iteratorUsing std::iteratorBefore C++17, implementing custom iterators was recommended to derive from std::iterator.Basic definition of std::iteratorStd::iterator has the following definition:template< class ...

Posted by gl_itch on Thu, 28 Oct 2021 21:44:01 +0200

8 C++STL set/multiset container details

2.8.1 introduction set/multiset container concept Set and multiset are a collection container, in which the elements contained in set are unique, and the elements in the collection are automatically arranged in a certain order. Set is implemented using the data structure of red black tree variant, which belongs to balanced binary tree. ...

Posted by hiberphoptik on Wed, 13 Oct 2021 02:42:50 +0200

Detailed explanation of c + + priority_queue

catalogue 1. Content: 2. Examples: 1) Examples of basic types: 2) For pair comparison, first compare the first element, the first is equal, and the second is equal   3) For custom types   3. Common uses:   1. Content: Since it is a queue, the header file #include < queue > must be included first. The difference betw ...

Posted by washbucket on Tue, 21 Sep 2021 08:30:37 +0200

STL learning notes string

STL learning notes (I) string c_str() const char *c_str(); c_ The str() function returns a pointer to the normal C string, with the same content as this string string s="123" printf("%s",s.c_str()) Add: insert() iterator insert( iterator i, const char &ch ); basic_string &insert( size_type index, const basic_string & ...

Posted by derrick24 on Sun, 19 Sep 2021 20:41:52 +0200