找回密码
 注册
查看: 441|回复: 0

R语言 externalVector包 gcAllocator-class()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-2-25 17:25:49 | 显示全部楼层 |阅读模式
gcAllocator-class(externalVector)
gcAllocator-class()所属R语言包:externalVector

                                        Class "gcAllocator", memory allocator class for external resources
                                         类“gcAllocator”,对外部资源的内存分配器类

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

A memory allocator class for external resources that allocates memory using R memory management system. The allocated memory is freed by the R garbage collector when all refernce to it is
一个外部资源使用R内存管理系统分配内存的内存分配器类。当所有的refernce是由R垃圾收集器释放分配的内存


类的对象----------Objects from the Class----------

Objects can be created by calls of the form new("gcAllocator").
创建对象可以通过检测的形式new("gcAllocator")。


延伸----------Extends----------

Class "externalAllocator", directly.
类"externalAllocator",直接。


方法----------Methods----------

Signature components for the methods:
签名组件的方法:

The class "externalResource"
类“externalResource”

The class of "gcAllocator"
类“gcAllocator”

The class "ANY"
类的“ANY”

The class "ANY"
类的“ANY”

The class "logical"
类的“逻辑”

The class "ANY"
类的“ANY”

Description of the methods:
方法描述:




allocate(resource, alloc, size, type, ...):  Allocate the external pointer in resource. If type is a basic vector object, then allocate an object of same mode with length size. Otherwise allocate size bytes of raw memory. The allocation is done by creating an R basic vector with same class as type and storing it in the protected field of the newly created external pointer. Ends with a call to initializeResource to initialize the resource
(分配资源,分配,大小,类型,...):分配resource的外部指针。 type如果是一个基本的矢量对象,然后分配长度size对象相同的模式。否则分配原始内存size字节。分配是通过创建一个R类型的同一类的基本向量,并存储在新创建的外部指针的保护领域。呼叫完initializeResource初始化resource




deallocate(resource, alloc):  Replace the protected field
释放(资源,分配):替换受保护的领域




external.size  Return the size of the allocated memory in
external.size返回分配的内存的大小




external.size<-(resource, copy, alloc, value):  If value is same as external.size(resource), then no action is taken. Otherwise, reallocate the memory in resource with new size value. If copy is TRUE (the default), then the new memory is initialized to the content of the old memory for the minimum of old and new
external.size < - (资源,复制,分配,价值):如果value作为external.size(resource)是相同的,那么不采取任何行动。否则,重新分配新的大小resource内存value。 copy如果是TRUE(默认),那么新的内存进行初始化,以老内存的内容,旧的和新的最低




reinitializePointer(resource, alloc):  If the object resource was saved as an R image (by serialization code, by saving the R workspace, or by an explicit call to save) then the raw memory pointer in any "externalptr" object in it would be set to 0. This method reinitializes the memory (if possible) by using the
reinitializePointer(资源,分配):如果对象resource被保存为一个R图像(序列化代码,保存的R工作区,或由一个显式的调用save),则原始内存指针任何"externalptr"在它的对象将被设置为0。使用此方法重新初始化的内存(如果可能)


举例----------Examples----------


library(externalVector)
## set a storage class[#设置存储类]
setClass("testStorage",
         representation(ptr="externalptr"),
         contains="externalResource")
setMethod("initializeResource", "testStorage",
          function(resource, ptr, size, type, ...)
       {
           resource@ptr <- ptr
           resource
       })
setMethod("allocator", "testStorage",
          function(resource)
          new("gcAllocator"))
setMethod("getPointer", "testStorage",
          function(resource)
          resource@ptr)
setMethod("allocatedSize", "testStorage",
          function(resource)
          32)
## Now create an object from the class[#现在创建一个类的对象]
x <- new("testStorage")
x
external.size(x)
external.size(x) <- 64
x
external.size(x)
deallocate(x)
x
external.size(x)

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2025-2-9 10:44 , Processed in 0.021765 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表