clone {hashmap}R Documentation

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.

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


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

[Package hashmap version 0.2.2 Index]