• Notes on C + + primer Chapter 12 dynamic memory


    shared_ PTR and unique_ Operations supported by PTR explain shared_ptrSP or unique_ ptr up Empty smart pointer, which can point to the object of type T p Use p as a conditional judgment, true if P points to an object *p Dereference p to get the object it points to p->mem Equivalent to (* P). […]

  • C + + programming 01 — the use of array and pointer


    The use of arrays and pointers 1. Array 1. One dimensional array //Data type array name [array length] 2. Two dimensional array //Data type array name [number of rows] [number of columns] = {(data 1, data 2), (data 3, data 4) ·} 2. Basic syntax of pointer int a=10; 3. Combination of const and pointer […]

  • B-Tree & B+Tree


    B-Tree The maximum number of child nodes in all nodes of B-tree becomes the order of B-tree, which is usually expressed by M. considering the efficiency of searching, it is generally required that M > = 3. An m-order B-tree is either an empty tree or an M-ary tree satisfying the following conditions.1) Each node […]

  • Build high-performance queue, you have to know the underlying knowledge!


    preface This article is included in the album:http://dwz.win/HjK, click to unlock more knowledge of data structure and algorithm. Hello, I’m brother Tong. In the previous section, we learned how to rewrite recursion as non recursion, in which the data structure used is mainly stack. Stack and queue are the most basic data structures in addition […]

  • The use of pointer and structure


    Previous articles in the go language introduction series: A summary of the basic grammar of go language introduction series (2) Go language introduction series (3): array and slice The use of map 1. Pointer If you’ve used C or C + +, you’re no stranger to the concept of pointers. We need to introduce two […]

  • Const_ cast,static_ cast, dynamic_ cast, reinterpret_ cast


    const_ Cast: used to convert const variables to non const variables int n = 5; int *k1 = const_ Cast (& n); // pointer *k1 = 1; int &k2 = const_ Cast (n); // reference k2 = 2; const int a = 10; int* b = const_cast(&a); *B = 11; // the attribute of pointer […]

  • The difference between dynamic method and static method


    Dynamic methods are called by objectsStatic methods are called by classes,Because the method is called through ISA and super pointer. Therefore, objects can only call methods of class objects, while class objects can call methods of metaclasses.

  • Can const member functions take non const pointers as return values?


    Let’s start with a piece of code class A { int *x; public: int *f() const { return x; } }; Member functionfReturn to private memberxI think it will modify the membersx, right? fyesconstMember function, I should add it before the return typeconstIs that right? constThe member function should guarantee that it cannot change any […]

  • Using mutex to synchronize multiple processes


    The function of the following program is to create a piece of shared memory, so that both the parent process and the child process can write data to it. However, it is required that another process can start to write after the parent process or the child process has finished writing, and all of them […]

  • Basic chapter: object object


    1 object memory structure and pointer compression to understand //Hotspot’s oop.hpp Class oopdesc in file class oopDesc { friend class VMStructs; private: volatile markOop _ Mark; // object header union _ Metadata {// klassoop class metadata pointer Klass* _klass; narrowKlass _compressed_klass; } _metadata; Object instance data memory consists of three parts,Object header,Actual data area、Memory alignment […]

  • Remember that you made a mistake because you shared variables


    Problems recur In models/ User.php var UserModel = new (User) controller if models.UserModel.Token == “” { models.UserModel.Token = “hello world” } becausevar UserModel = new (User)OnlynewAt one time, each request shares the value of this variable. It will lead to the futureifWill it only be executed once, or will it be obedientnewA new pointer. Darlingnew […]

  • The way of algorithm learning, quick sorting of sorting (Java implementation)


    Today, I suddenly want to write a sort. I wrote it before, and then I made mistakes all the time. Then I Baidu it for a while, and I read the method of others’ writing, and I tried to write one myself. Next, I’ll explain the idea of quick sort and the implementation code. Quick […]