01Qt中的隐式共享
隐式共享
隐式共享又称为回写复制(copy on write)。当两个对象共享同一分数据时(通过浅拷贝实现数据共享),如果数据不改变,则不进行数据的复制。而当某个对象需要需要改变数据时,则进行深拷贝。
程序在处理共享对象时,使用深拷贝和浅拷贝这两种方式复制对象。所谓深拷贝,就是生成对象的一个完整复制品;而浅拷贝则是一个引用复制(如今复制指向共享数据的指针)。显然,执行一个深拷贝的代价是昂贵的,要占用更多的内存和 CPU 资源;而浅拷贝的效率则很好,他仅需设置一个指向共享数据库的指针几修改引用计数的值。
隐式共享可以降低对内存和 CPU 资源的使用,提高程序的运行效率。它使得在函数中(如参数、返回值)使用值传递更有效率。
QString 类采用隐式共享计数,将深拷贝和浅拷贝有机的结合起来。
#include <QCoreApplication>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QString str1 = "data";
QString str2 = str1;
//QString的data_ptr()函数返回字符存储区地址
qDebug() << "浅拷贝:" ;
qDebug() << "str1.data_ptr(): " << str1.data_ptr();
qDebug() << "str2.data_ptr(): " << str2.data_ptr();
str2[3] = 'e';
str2[0] = 'f';
qDebug() << "深拷贝:" ;
qDebug() << "str1.data_ptr(): " << str1.data_ptr();
qDebug() << "str2.data_ptr(): " << str2.data_ptr();
return a.exec();
}
输出结果为:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAa4AAAF/CAYAAAARly0QAAAgAElEQVR4nO3df4wcZ33H8e/9zIUfSQypRNQq0MSmJbhqVELUnttgVQJhJ0IWf1iEkEa01bkqAvsfkCqlUiUioZJ/zlCQbEWtQpJCrYpaxNiBVG1ScFKJ8EPUSavcBUxCfoAhPv9IfL69u+3O3M352bnneeaZH7sz3733K9rcemfmmWee3Z3PPs/M7gzNz8+3OyS6LS8vy9LSkiwuLsrMdz8of/F/9woAAP127PbrZGxsTEZHR2VkZESGh4fj29DQkIwmodUdXrPyrf9tiwyJnPjM++quPwBgA9n6+cel1WrFIWXeonyK/g6ng2vl9g75+Ee/Xnfd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EFwAAFUILgCAKgQXAEAVggsAoArBBQBQheACAKhCcAEAVCG4AACqEFwAAFUILgCAKgQXAEAVggsAoArBBQBQheACAKhCcAEAVCG4AACqEFwAAFUILgCAKgQXAEAVggsAoArBBQBQheACAKhCcAEAVCG4AACqEFwAAFUILgCAKgQXAEAVggsAoIozuNrtdj/rAQCAVZRHZiZZg4vQAgBUZd++fbkejyRhZeZRcn/Y/AcAAL2QDilfaGWJg2toaKhcjQAAyJCEVZnQiliHCgkyAEBVpqen1+6boWU+nhblUHIzH4s4T84gvAAAVUmHlC+00tIBNpz8Iz0BAIAqJWEVElpmjyudU85jXIQYAKBqoT2tdHB19bhCZgIAoJ+Gh4etuRTdRtMBFXfDVhcAAKAOrtBaGypMZooCKwmt6C8AAHWIMmhkZCS+OXtcXWm2GmAAANQhCiyzI2UOHY4mM5mhFS0wOroy6e1/e6S2igMAdNn6+ccrKSfKoHRgrd0/f/58e3l5Of7Zp+jv4uLi2q3VasW3paWltVs0jzm/+Tf9u1IAAKSlR/jMXlXScRobG4v/JrekBxZPTxaOAsfscZkrSAIr+ZuElXk/QnABALKYZ66bwWWGUxJgyWNm72vUTL6kkPQKogWj0Ir+ElwAgDJ8wWXeN0Or6+SMdCHJQkkARf+OginpldmGChkmBAC4mNlgOyHQdla72QOz9rgi0QNRECV/bacg+o5rEV4AgBDO72cZwWUGWDrUur6AbAsxcyVmzyv5mw4sggsA4OPrdbl6YOZfa3ClC44kIZaEVDq4klLPqCoAAAATSURBVGkAAJhcQ4XJX1/vy3b7f4fYLVVSFyXOAAAAAElFTkSuQmCC" alt="image">
01Qt中的隐式共享的更多相关文章
- 关于QT中的隐式共享
网上关于隐式共享的解释很多,在此不再陈述.本文主要是记录一下自己学习隐式共享的坑点: 即:隐式共享只发生在非指针的情况下!!!! 如下代码: QImage image1; QImage image2; ...
- Qt——数据的隐式共享
一.隐式共享类 在Qt中有很多隐式共享类( Implicitly Shared Classes ),什么是隐式共享呢,请参考官方文档的说明. 好吧,翻译一下—— 许多C++类隐式地共享数据,使得资源使 ...
- Qt隐式共享与显式共享
版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/Amnes1a/article/details/69945878Qt中的很多C++类都使用了隐式数据共 ...
- C++中的深拷贝和浅拷贝 QT中的深拷贝,浅拷贝和隐式共享
下面是C++中定义的深,浅拷贝 当用一个已初始化过了的自定义类类型对象去初始化另一个新构造的对象的时候,拷贝构造函数就会被自动调用.也就是说,当类的对象需要拷贝时,拷贝构造函数将会被调用.以下情况都会 ...
- 可恶的QT隐式共享
这个问题隐藏的很深,一般不容易察觉它造成的问题,而只是享受它提供的好处(节省内存,而且速度更快). 但我发现它现在至少造成两个问题: 1. 把大量的QString放到QMap里,使用完毕后清空QMap ...
- QVector 和vector的比较(QVector默认使用隐式共享,而且有更多的函数提供)
QVector和vector的比较: Qvector默认使用隐式共享,可以用setSharable改变其隐式共享.使用non-const操作和函数将引起深拷贝.at()比operator[](),快, ...
- Qt隐式共享机制
1.浅拷贝 浅拷贝-引用类型.浅拷贝是指源对象与拷贝对象共用一份实体,仅仅是引用的变量不同(名称不同),对其中任何一个对象的改动都会影响另外一个对象. 2.深拷贝 而深拷贝-值类型.深拷贝是指源对象与 ...
- Scala 深入浅出实战经典 第62讲:Scala中上下文界定内幕中的隐式参数实战详解
王家林亲授<DT大数据梦工厂>大数据实战视频 Scala 深入浅出实战经典(1-87讲)完整视频.PPT.代码下载: 百度云盘:http://pan.baidu.com/s/1c0noOt ...
- Scala 中的隐式转换和隐式参数
隐式定义是指编译器为了修正类型错误而允许插入到程序中的定义. 举例: 正常情况下"120"/12显然会报错,因为 String 类并没有实现 / 这个方法,我们无法去决定 Stri ...
随机推荐
- LDAP第三天 MySQL+LDAP 安装
https://www.easysoft.com/applications/openldap/back-sql-odbc.html OpenLDAP 使用 SQLServer 和 Oracl ...
- JSONPath中的表达式
在JsonPath中使用表达式是一个非常好的功能,可以使用简洁和复杂的JsonPath.JsonPath中的表达式基本上是评估为布尔值的代码片段.基于结果,仅选择满足标准的节点.让我们看一下它的更多内 ...
- Codeforces Round #566 (Div. 2) B. Plus from Picture
链接: https://codeforces.com/contest/1182/problem/B 题意: You have a given picture with size w×h. Determ ...
- 得到web.xml中servletContext的context-param
import org.springframework.web.context.ContextLoader; // web.xml文件中已经启用数据权限 String enableDataSecurit ...
- 线程池(3)Executors.newCachedThreadPool
例子: ExecutorService es = Executors.newCachedThreadPool(); try { for (int i = 0; i < 20; i++) { Ru ...
- java preparement
1.建立链接 Connection conn = getDataSource().getConnection(); PreparedStatement ps = null; 2不自动 Commit 不 ...
- HDU 1024 A - Max Sum Plus Plus DP + 滚动数组
http://acm.hdu.edu.cn/showproblem.php?pid=1024 刚开始的时候没看懂题目,以为一定要把那n个数字分成m对,然后求m对中和值最大的那对 但是不是,题目说的只是 ...
- 中介者模式和php实现
中介者模式: 中介者模式(Mediator Pattern)定义:用一个中介对象来封装一系列的对象交互,中介者使各对象不需要显式地相互引用,从而使其耦合松散,而且可以独立地改变它们之间的交互.中介者模 ...
- CF713C Sonya and Problem Wihtout a Legend & hihocoder1942 单调序列
这两个题是一样的,不过数据范围不同. 思路1: 在CF713C中,首先考虑使生成序列单调不下降的情况如何求解.因为单调上升的情况可以通过预处理将a[i]减去i转化成单调不下降的情况. 首先,生成的序列 ...
- RxJava四个基础接口
Publisher Subscriber Subscription Processor ----------------------------------- public interface Pub ...