`
woainike
  • 浏览: 77764 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
最近访客 更多访客>>
社区版块
存档分类
最新评论

Copy Functions

 
阅读更多

 

 

Copy Functions

 

 

一般情况下,一个标准的复制操作也可能被称为简单的任务,当您使用=操作符指定一个变量到另一个例如,表达myInt2= myInt1导致整数内容myInt1用于myInt1myInt2使用的内存的内存复制两个独立的区域内存复制操作包含相同的值然而,如果试图以这种方式复制的核心基础对象(Core Foundation object),要知道,你不会复制对象本身,只有引用(Reference)对象


例如一个新核心基金可能会认为,为了使一个CFString对象副本将使用表达式myCFString2= myCFString1再次表达实际字符串数据复制因为myCFString1myCFString2必须有CFStringRef类型这种表达复制对象的引用复制操作之后有两个副本CFString这种类型的副本是非常快的,因为只有引用(Reference)被复制但重要的是要记住,复制这样一个可变对象危险方案,使用全局变量如果一个应用程序的一部分改变一个对象使用引用(Reference)的副本,有没有其他地方方案,其中引用副本知道数据已经改变方式

如果要复制一个对象必须使用核心基金提供专门用于此目的功能之一继续CFString例如,你使用CFStringCreateCopy创造一个全新CFString对象包含相同的原始数据 CreateCopy“功能提供核心基础类型变种CreateMutableCopy它返回一个可以修改对象副本

 

 

 

 

Shallow Copy 

 

复制复合对象集合对象可以包含其他对象对象还必须进行谨慎正如您所期望那样使用=操作符执行重复的对象引用这些对象结果副本对比简单CFStringCFData对象CreateCopy提供化合物CFArrayCFSet对象功能实际执行浅拷贝浅拷贝这些对象情况创建一个新的集合对象原始集合的内容重复对象引用复制到新的容器这种类型的复制是非常有用例如如果你有一个数组,不可改变要重新排序这种情况下希望重复所有包含的对象因为没有必要改变他们为什么使用额外的内存你想要的只是一套包括要改变对象在这里适用同样的风险复制的简单类型对象引用

 

 

Deep Copy

 

当你想创建一个全新的复合对象必须执行一个深拷贝一个深拷贝复制复合对象以及其包含所有对象内容当前版本核心基础包括执行财产清单复制(见CFPropertyListCreateDeepCopy功能如果你想创建其他结构拷贝你可以执行深拷贝递归下降复合对象复制所有内容逐一自己照顾在执行此功能作为复合对象可以是递归,他们可能直接或间接地包含了自己这可能会导致递归循环

 

 

 

可简单的这样理解。

copy的目的 就是复制对象 也就是说要新建一个对象

不可变对象copy == 对象retain(内存优化机制的结果)
可变对象copy     == 新建了个不可变对象
不可变/可变对象mutablecopy == 新建一个可变对象

分享到:
评论

相关推荐

    GObject Reference Manual

    Copy functions Conventions Non-Instantiable non-classed fundamental types Instantiable classed types: objects Initialization and Destruction Non-instantiable classed types: Interfaces. Interface ...

    C++ 标准 ISO 14882-2011

    Contents Contents iii List of Tables xi List of Figures xv 1 General 1 1.1 Scope . . . . ....1.2 Normative references ....1.3 Terms and definitions ....1.4 Implementation compliance ....1.5 Structure of this ...

    Google C++ International Standard.pdf

    Contents Contents ii List of Tables x List of Figures xiv 1 Scope 1 2 Normative references 2 3 Terms and definitions 3 4 General principles 7 4.1 Implementation compliance . ....4.2 Structure of this ...

    JavaScript Objects Functions and Arrays Explained

    JavaScript Objects Functions and Arrays Explained covers a lot of material as you may see from the index below. However, each chapter is self-contained and easy to understand with plenty of ...

    php中文完全开发手册

    34. Duplicating Variable Contents: The Copy Constructor 35. Returning Values 36. Printing Information 37. Startup and Shutdown Functions 38. Calling User Functions 39. Initialization File Support 40. ...

    teracopy2b4

    TeraCopy is a compact program designed to copy and move files at the ... TeraCopy can completely replace Explorer copy and move functions, allowing you work with files as usual. Full Unicode support.

    Str---Copy.rar_There There

    there are lot of string program without using string functions in java/\.

    CAPLdll - Copy.7z

    CANoe的官方代码,指导怎么通过VS...In CAPL programs you can call functions which you have implemented in your own Windows DLL. In doing so, the function from the DLL are exported through a function table.

    ssd5 ex4 给需要帮助的人。这是ssd5 ex4

    Some STL functions to consider are copy, remove_if, for_each, and find. The member function find of class string should be considered as well. Regardless of the STL functions used, a solution should ...

    深度探索模C++对象模型PDF

    4.4 指向Member Functions的指针(Pointer-to-Member Functions) 支持“指向Virtual Member Functions”之指针 在多重继承之下,指向Member Functions的指针 “指向Member Functions之指针”的效率 4.5 Inline ...

    深度探索C++对象模型 超清版

    4.4 指向Member Functions的指针(Pointer-to-Member Functions) 支持“指向Virtual Member Functions”之指针 在多重继承之下,指向Member Functions的指针 “指向Member Functions之指针”的效率 4.5 Inline ...

    C++ The Complete Reference, 4th Edition - Copy

    demonstrates the keywords, syntax, functions, classes, and features that define the C++ language. More specifically, this book fully describes Standard C++. This is the version of C++ defined by the ...

    DelphiSpeedUpV16

    This will copy the DelphiSpeedUpX.dll and DelphiSpeedUpLoaderX.bpl to $(DELPHI)\bin and it registers the DLL as an Known IDE package in the registry. === How to uninstall === Start the ...

    《深度探索C++对象模型》(Stanley B·Lippman[美] 著,侯捷 译)

    4.4 指向Member Functions的指针(Pointer-to-Member Functions) 支持“指向Virtual Member Functions”之指针 在多重继承之下,指向Member Functions的指针 “指向Member Functions之指针”的效率 4.5 Inline ...

    Prentice.Hall.C++.for.Business.Programming.2nd.Edition.2005.chm

    The Copy Constructor 528 Section 12.3. Using const with Classes 540 Section 12.4. Objects, Functions and Pointers 556 Section 12.5. Dynamic Allocation of Objects 581 Section 12.6. Static Data...

    DLL Export Viewer v1.26

    You can easily copy the memory address of the desired function, paste it into your debugger, and set a breakpoint for this memory address. When this function is called, the debugger will stop in the ...

    Think in C++ 英文版(含卷一、卷二)

    11: References & the Copy-Constructor 12: Operator Overloading 13: Dynamic Object Creation 14: Inheritance & Composition 15: Polymorphism & Virtual Functions 16: Introduction to Templates A: Coding ...

    COM Standard Library

    However, it requires that a copy of AutoHotkey.exe exist in the directory above the compiler directory (which is normally the case). If AutoHotkey.exe is absent, the compiler still works but library ...

    flash .swf

    Example Here's a simple example of the JW Image Rotator embedded in a page. Copy-paste the source code and put the files on your site to get started...A tutorial with all functions of the javascript API.

    tolua# 1.0.6.312

    which can automatically generate the binding code to access Unity from Lua and map c# constants, variables, functions, properties, classes, and enums to Lua. tolua# grows up from cstolua. it's goal ...

Global site tag (gtag.js) - Google Analytics