当前位置:网站首页>U++ learning notes - relaxation
U++ learning notes - relaxation
2022-07-02 22:34:00 【It's a bald rabbit】
Because the default constructed array does not allocate memory , So the relaxation is initially zero .GetSlack You can use this function to find out how much slack there is in the array . Before the container is reallocated , The maximum number of elements that the array can hold can be through Max Function to obtain .GetSlack amount to and Between Max Bad Num:
TArray<int32> SlackArray;
// SlackArray.GetSlack() == 0
// SlackArray.Num() == 0
// SlackArray.Max() == 0
SlackArray.Add(1);
// SlackArray.GetSlack() == 3
// SlackArray.Num() == 1
// SlackArray.Max() == 4
SlackArray.Add(2);
SlackArray.Add(3);
SlackArray.Add(4);
SlackArray.Add(5);
// SlackArray.GetSlack() == 17
// SlackArray.Num() == 5
// SlackArray.Max() == 22The above is TArray Automatic expansion of
There is one Reset And Empty Similar functions , Except if the current assignment has provided the requested slack, It will not free memory . however , If requested slack more , It will allocate more memory :
SlackArray.Reset(0);
// SlackArray.GetSlack() == 3
// SlackArray.Num() == 0
// SlackArray.Max() == 3
SlackArray.Reset(10);
// SlackArray.GetSlack() == 10
// SlackArray.Num() == 0
// SlackArray.Max() == 10 Last , You can use this function to delete all slack, The Shrink Function will adjust the allocated size to the minimum size required to accommodate the current element .Shrink It has no effect on the elements in the array :
SlackArray.Add(5);
SlackArray.Add(10);
SlackArray.Add(15);
SlackArray.Add(20);
// SlackArray.GetSlack() == 6
// SlackArray.Num() == 4
// SlackArray.Max() == 10
SlackArray.Shrink();
// SlackArray.GetSlack() == 0
// SlackArray.Num() == 4
// SlackArray.Max() == 4边栏推荐
- From personal heroes to versatile developers, the era of programmer 3.0 is coming
- Socket socket c/s end process
- From "bronze" to "King", there are three secrets of enterprise digitalization
- Pointer - function pointer
- Kubernetes resource object introduction and common commands (4)
- The failure rate is as high as 80%. What should we do about digital transformation?
- Build your own website (22)
- LightGBM原理及天文数据中的应用
- Leetcode theme [array] -169- most elements
- [leetcode] sword finger offer 04 Search in two-dimensional array
猜你喜欢

Pointer and string

【外刊】睡眠与减肥

Utilisation de simpletk - 4. Question étrange

Based on asp Net (used mobile phone sales management system) +asp Net+c # language +vs2010+ database can be used for course design and post design learning
![[shutter] shutter page life cycle (initialization period | createstate | initstate | update period | build | destroy period | dispose)](/img/07/6f2dfb543cb0ab4f27169da7e6ad07.jpg)
[shutter] shutter page life cycle (initialization period | createstate | initstate | update period | build | destroy period | dispose)

Ransack combined condition search implementation

Reading experience of just because

基于ASP.net的手机销售管理系统(二手手机销售管理系统)+ASP.NET+C#语言+VS2010+数据库可以用于课设、毕设学习

Leetcode circular linked list (fast and slow pointer) code line by line interpretation

Struct, bit segment, enumeration, union
随机推荐
Web侧防御指南
Utilisation de simpletk - 4. Question étrange
任务和特权级保护
Socket socket c/s end process
scrcpy这款软件解决了和同事分享手机屏幕的问题| 社区征文
The failure rate is as high as 80%. What should we do about digital transformation?
540. Single element in ordered array
《乔布斯传》英文原著重点词汇笔记(十一)【 chapter nine】
Notes on key vocabulary of the original English book biography of jobs (IX) [chapter seven]
Simpleitk use - 3 Common operations
UE4 UI自适应屏幕
About test cases
【C 题集】of Ⅴ
Kubernetes resource object introduction and common commands (4)
The book "new programmer 002" is officially on the market! From "new database era" to "software defined car"
Share how to make professional hand drawn electronic maps
: last child does not take effect
攻防世界pwn题:Recho
[shutter] shutter gesture interaction (small ball following the movement of fingers)
Market Research - current situation and future development trend of carob chocolate market