File: clone.R

package info (click to toggle)
r-cran-bit 4.0.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 996 kB
  • sloc: ansic: 5,083; makefile: 6
file content (48 lines) | stat: -rw-r--r-- 1,168 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# clone utilities for bit,bit64,ff
# (c) 2014 Jens Oehlschlägel
# Licence: GPL2
# Provided 'as is', use at your own risk
# Created: 2014-03-02


#' Cloning ff and ram objects
#' 
#' \command{clone} physically duplicates objects and can additionally change
#' some features, e.g. length.
#' 
#' \command{clone} is generic.  \command{clone.default} handles ram objects. 
#' Further methods are provided in package 'ff'. 
#' \command{still.identical} returns TRUE if the two atomic arguments still
#' point to the same memory.
#' 
#' @param x \code{x} an R object
#' @param \dots further arguments to the generic
#' @return an object that is a deep copy of x
#' @author Jens Oehlschlägel
#' @seealso \code{clone.ff}, \code{\link{copy_vector}}
#' @keywords IO data
#' @examples
#' 
#'   x <- 1:12
#'   y <- x
#'   still.identical(x,y)
#'   y[1] <- y[1]
#'   still.identical(x,y)
#'   y <- clone(x)
#'   still.identical(x,y)
#'   rm(x,y); gc()
#' 
#' @export
clone  <- function(x, ...){
  UseMethod("clone")
}


#' @describeIn clone default method uses R's C-API 'duplicate()'
#' @export
clone.default <- function(
  x
, ... # ignored here
){
  .Call(C_R_duplicate, x)
}