Learn R Programming

hashmap (version 0.2.2)

clone: Clone a Hashmap

Description

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

Usage

clone(x)

Arguments

x

an object created by a call to hashmap.

Value

a Hashmap identical to the input object.

Details

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

See Also

hashmap

Examples

Run this code
# NOT RUN {
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
# }

Run the code above in your browser using DataLab