当前位置:网站首页>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边栏推荐
- Dynamic memory allocation (malloc calloc realloc free)
- Market Research - current situation and future development trend of preclinical medical device testing service market
- LxC terminal login method
- Record the functions of sharing web pages on wechat, QQ and Weibo
- kubernetes资源对象介绍及常用命令(四)
- Servicemesh mainly solves three pain points
- Phpcms realizes the direct Alipay payment function of orders
- Market Research - current market situation and future development trend of third-party data platform
- Socket socket c/s end process
- Struct, bit segment, enumeration, union
猜你喜欢

Kubernetes resource object introduction and common commands (4)

"New programmer 003" was officially launched, and the cloud native and digital practical experience of 30+ companies such as Huawei and Alibaba

#include errors detected. Please update your includePath.

From personal heroes to versatile developers, the era of programmer 3.0 is coming

It's not easy to say I love you | use the minimum web API to upload files (swagger support) # yyds dry inventory #

Introduction to victoriametrics

C language, to achieve three chess games

540. Single element in ordered array

Utilisation de simpletk - 4. Question étrange

What "real skills" should a million year old cloud native developer master? Alibaba, Tencent, meituan and byte decrypt together
随机推荐
An overview of the development of affective computing and understanding research
Une semaine de vie
Market Research - current situation and future development trend of carob chocolate market
Market Research - current market situation and future development trend of intravenous injection (IV) bottles
Attack and defense world PWN question: Echo
From "bronze" to "King", there are three secrets of enterprise digitalization
About test cases
U++ 学习笔记 堆
Bridge emqx cloud data to AWS IOT through the public network
技术人创业:失败不是成功,但反思是
[QT] QT multithreading development - four methods to realize multithreading design
攻防世界pwn题:Recho
Official announcement! The golden decade of new programmers and developers was officially released
[leetcode] sword finger offer 11 Rotate the minimum number of the array
情感计算与理解研究发展概述
Radis:Linux上安装Redis(步骤)
开发者分享 | HLS, 巧用AXI_master总线接口指令的定制并提升数据带宽-面积换速度...
Service visibility and observability
《乔布斯传》英文原著重点词汇笔记(九)【 chapter seven】
一周生活