当前位置:网站首页>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() == 22
The 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
边栏推荐
- Simpleitk use - 3 Common operations
- U++ 学习笔记 ----松弛
- [shutter] shutter page life cycle (initialization period | createstate | initstate | update period | build | destroy period | dispose)
- Daily book CSO advanced road first exposed
- Unity3d learning notes 4 - create mesh advanced interface
- Market Research - current market situation and future development trend of aircraft audio control panel system
- Market Research - current situation and future development trend of marine clutch Market
- 100 important knowledge points that SQL must master: using cursors
- 【C 题集】of Ⅴ
- 【AUTOSAR-DCM】-4.3-UDS $22和$2E服务如何读取和写入NVM数据
猜你喜欢
Simpleitk use - 3 Common operations
情感计算与理解研究发展概述
phpcms实现订单直接支付宝支付功能
[shutter] shutter application theme (themedata | dynamic modification theme)
The failure rate is as high as 80%. What should we do about digital transformation?
How to write a good program when a big book speaks every day?
Get off work on time! Episode 6 of Excel Collection - how to split and count document amounts
【ODX Studio编辑PDX】-0.1-如何快速查看各Variant变体间的支持的诊断信息差异(服务,Sub-Function...)
Commodity information management system (C language document version)
Etcd raft protocol
随机推荐
Secondary development of ANSYS APDL: post processing uses command flow to analyze the result file
Sql service intercepts string
Unity3d learning notes 4 - create mesh advanced interface
New feature of go1.18: introduce new netip Network Library
情感计算与理解研究发展概述
From "bronze" to "King", there are three secrets of enterprise digitalization
ArrayList analysis 2: pits in ITR, listiterator, and sublist
[shutter] shutter application theme (themedata | dynamic modification theme)
Bridge emqx cloud data to AWS IOT through the public network
#include errors detected. Please update your includePath.
C语言,实现三子棋小游戏
20220702-程序员如何构建知识体系?
Market Research - current market situation and future development trend of high tibial osteotomy plate
What is it that makes you tremble? Those without fans can learn
ServiceMesh主要解决的三大痛點
[staff] Sibelius 7.5.1 score software installation (software download | software installation)
How to write a good program when a big book speaks every day?
服务可见可观测性
kubernetes资源对象介绍及常用命令(四)
将 EMQX Cloud 数据通过公网桥接到 AWS IoT