File tree Expand file tree Collapse file tree 2 files changed +40
-1
lines changed
Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change 9999| ---- | ------------------------------------------------- | ------------------------------------------------------------------- |
100100| ✅ | [ wardseptember] ( https://github.com/wardseptember ) | [ notes(Java 实现)] ( https://github.com/wardseptember/notes ) |
101101| ✅ | [ dashidhy] ( https://github.com/dashidhy ) | [ algorithm-pattern-python(Python 实现)] ( https://github.com/dashidhy/algorithm-pattern-python ) |
102- | ✅ | [ da183] ( https://github.com/da183 ) | [ algorithm-pattern-python(C++ 实现)] ( https://github.com/da183/algorithm-pattern-cpp ) |
102+ | ✅ | [ da183] ( https://github.com/da183 ) | [ algorithm-pattern-cpp(C++ 实现)] ( https://github.com/da183/algorithm-pattern-cpp ) |
103+
104+ [ 自己的一点总结] ( punch_in/learned_along_the_journey.md )
Original file line number Diff line number Diff line change 1+ [ toc]
2+ #### 注意边界
3+ 太多次越界了,很多时候CLion并不会报错~~ 难道是我漏看了exit code?~~
4+ 一提交运行直接崩了
5+
6+ ### C++相关
7+ #### 初始化列表的使用要小心
8+ ``` c++
9+ vector<int > ret (n + 1, 1); // 初始化为n+1个1
10+ vector<int > ret{n + 1, 1}; // 初始化为n + 1, 1两个元素!
11+ ```
12+
13+ #### 普通数组也可以使用range for进行遍历
14+
15+ #### push_back vs emplace_back
16+ [C++ difference between emplace_back and push_back function
17+ ](http://candcplusplus.com/c-difference-between-emplace_back-and-push_back-function)
18+ 1. 如果对象的构造函数参数不止一个,push_back只能接受对象实例;emplace_back可以接受构造函数的参数!
19+ push_back只能接受对象实例或者单参数版本的构造函数的参数(通过隐式类型转换,如果声明为explicit也不行
20+ 而emplace_back可以接受多个构造函数参数
21+
22+ 2. 性能
23+ 对于内置类型没区别,对于自定义类型,emplace_back性能更好
24+ 如果传入的是对象实例则没区别,如果传入的是构造对象参数
25+ * push_back
26+ 如果直接传入构造函数参数,则通过隐式类型转换创建临时对象
27+ 1. 调用构造函数创建临时对象
28+ 2. 在vector中创建一个临时对象的拷贝
29+ 3. 销毁临时对象
30+ * emplace_back
31+ 不会创建临时对象,而是直接在vector中创建对象。避免了创建不必要的临时对象
32+
33+
34+ ### JetBrians产品中关于GitHub的fork、pull request使用
35+ [官方文档](https://www.jetbrains.com/help/idea/contribute-to-projects.html)
36+ 需要先**VCS | Git | Rebase my GitHub fork**
37+ 之后就可以看到upstream
You can’t perform that action at this time.
0 commit comments