当前位置:网站首页>U++ 学习笔记 ----松弛
U++ 学习笔记 ----松弛
2022-07-02 22:01:00 【是秃头的兔子呀】
由于默认构造的数组不分配内存,因此松弛度最初为零。GetSlack您可以使用该函数找出数组中有多少松弛。在容器重新分配之前,数组可以容纳的最大元素数可以通过Max函数获得。GetSlack相当于 和 之间的Max差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以上为TArray的自动扩容
有一个Reset与 Empty 类似的函数,除了如果当前分配已经提供了请求的 slack,它不会释放内存。但是,如果请求的 slack 较大,它将分配更多内存:
SlackArray.Reset(0);
// SlackArray.GetSlack() == 3
// SlackArray.Num() == 0
// SlackArray.Max() == 3
SlackArray.Reset(10);
// SlackArray.GetSlack() == 10
// SlackArray.Num() == 0
// SlackArray.Max() == 10最后,您可以使用该函数删除所有 slack,该Shrink函数会将分配的大小调整为容纳当前元素所需的最小大小。Shrink对数组中的元素没有任何影响:
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边栏推荐
- "Actbert" Baidu & Sydney University of technology proposed actbert to learn the global and local video text representation, which is effective in five video text tasks!
- 2019 Nanchang (relive the classic)
- 20220702 how do programmers build knowledge systems?
- APP页面分享口令Rails实现
- The book "new programmer 002" is officially on the market! From "new database era" to "software defined car"
- ServiceMesh主要解决的三大痛點
- ArrayList analysis 2: pits in ITR, listiterator, and sublist
- [shutter] shutter opens a third-party application (url|launcher plug-in search and installation | url| launcher plug-in official example | open browser | open a third-party application)
- 《ActBERT》百度&悉尼科技大学提出ActBERT,学习全局局部视频文本表示,在五个视频-文本任务中有效!
- [shutter] shutter layout component (wrap component | expanded component)
猜你喜欢

Off chip ADC commissioning record

tinymce可视化编辑器增加百度地图插件

Blue Bridge Cup Winter vacation homework (DFS backtracking + pruning)

Kubernetes resource object introduction and common commands (4)

How to write a good program when a big book speaks every day?

What "real skills" should a million year old cloud native developer master? Alibaba, Tencent, meituan and byte decrypt together

pip安裝whl文件報錯:ERROR: ... is not a supported wheel on this platform

phpcms实现订单直接支付宝支付功能

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

情感计算与理解研究发展概述
随机推荐
Share how to make professional hand drawn electronic maps
kubernetes资源对象介绍及常用命令(四)
Blue Bridge Cup Winter vacation homework (DFS backtracking + pruning)
Get off work on time! Episode 6 of Excel Collection - how to split and count document amounts
scrcpy这款软件解决了和同事分享手机屏幕的问题| 社区征文
【剑指 Offer】56 - I. 数组中数字出现的次数
*C language final course design * -- address book management system (complete project + source code + detailed notes)
Technological Entrepreneurship: failure is not success, but reflection is
: last child does not take effect
Gee: (II) resampling the image
[shutter] shutter page life cycle (initialization period | createstate | initstate | update period | build | destroy period | dispose)
Market Research - current market situation and future development trend of night vision goggles for pilots
App page sharing password rails implementation
Web side defense Guide
ArrayList analysis 2: pits in ITR, listiterator, and sublist
一周生活
Servicemesh mainly solves three pain points
Market Research - current market situation and future development trend of third-party data platform
[shutter] shutter application life cycle (foreground state resumed | background state paused | inactive | component separation state detached)
记录一下微信、QQ、微博分享web网页功能