当前位置:网站首页>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边栏推荐
- [leetcode] sword finger offer 04 Search in two-dimensional array
- 关于PHP-数据库的 数据读取,Trying to get property 'num_rows' of non-object?
- Market Research - current situation and future development trend of anterior cruciate ligament (ACL) reconstruction Market
- Task and privilege level protection
- [ODX studio edit PDX] -0.1- how to quickly view the differences in supported diagnostic information between variant variants (service, sub function...)
- From personal heroes to versatile developers, the era of programmer 3.0 is coming
- Market Research - current market situation and future development trend of marine wet exhaust hose
- Daily book CSO advanced road first exposed
- C language, to achieve three chess games
- U++ 学习笔记 ----松弛
猜你喜欢

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

《ActBERT》百度&悉尼科技大学提出ActBERT,学习全局局部视频文本表示,在五个视频-文本任务中有效!

Phpcms realizes the direct Alipay payment function of orders

Infrastructure is code: a change is coming

Secondary development of ANSYS APDL: post processing uses command flow to analyze the result file

腾讯三面:进程写文件过程中,进程崩溃了,文件数据会丢吗?

Reading experience of just because

The difference between include < > and include ""

Introduction to victoriametrics

Pointer and string
随机推荐
Introduction to victoriametrics
sql service 截取字符串
New feature of go1.18: introduce new netip Network Library
C language, to achieve three chess games
Dynamic memory allocation (malloc calloc realloc free)
Web侧防御指南
[shutter] shutter gesture interaction (small ball following the movement of fingers)
Perceptron model and Application
数据库系统概论第一章简答题-期末考得怎么样?
Market Research - current situation and future development trend of sickle cell therapy Market
Tencent three sides: in the process of writing files, the process crashes, and will the file data be lost?
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
Market Research - current situation and future development trend of cell-based seafood market
The difference between include < > and include ""
Pointer - function pointer
540. Single element in ordered array
服务可见可观测性
"New programmer 003" was officially launched, and the cloud native and digital practical experience of 30+ companies such as Huawei and Alibaba
Market Research - current market situation and future development trend of intravenous injection (IV) bottles
Using emqx cloud to realize one machine one secret verification of IOT devices