clone: Clone a Hashmap

Description Usage Arguments Details Value See Also Examples

View source: R/clone.R

Description

clone creates a deep copy of a Hashmap so that modifications made to the cloned object do not affect the original object.

Usage

1
clone(x)

Arguments

x

an object created by a call to hashmap.

Details

Since the actual cloning is done in C++, y <- clone(x) should be much more efficient than y <- hashmap(x$keys(), x$values()).

Value

a Hashmap identical to the input object.

See Also

hashmap

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
x <- hashmap(letters[1:5], 1:5)

## shallow copy
y <- x
y[["a"]] <- 999

## original is affected
x[["a"]] == 999

z <- clone(x)
z[["c"]] <- 888

## original not affected
x[["c"]] == 888

hashmap documentation built on Nov. 17, 2017, 4:46 a.m.