| hashmap {hashmap} | R Documentation |
Create a new Hashmap instance
hashmap(keys, values, ...)
keys |
an atomic vector representing lookup keys |
values |
an atomic vector of values associated with |
... |
other arguments passed to |
The following atomic vector types are currently supported for
keys:
integer
numeric
character
Date
POSIXct
The following atomic vector types are currently supported for
values:
logical
integer
numeric
character
complex
Date
POSIXct
a Hashmap object
Hashmap-class for a more detailed
discussion of available methods
x <- replicate(10e3,
paste0(sample(letters, 12, TRUE),
collapse = "")
)
y <- rnorm(length(x))
z <- sample(x, 100)
H <- hashmap(x, y)
all.equal(y[match(z, x)], H[[z]])
## Not run:
microbenchmark::microbenchmark(
"R" = y[match(z, x)],
"H" = H[[z]],
times = 500L
)
## End(Not run)