hashmap: Atomic vector hash map

Description Usage Arguments Details Value See Also Examples

Description

Create a new Hashmap instance

Usage

1
hashmap(keys, values, ...)

Arguments

keys

an atomic vector representing lookup keys

values

an atomic vector of values associated with keys in a pair-wise manner

...

other arguments passed to new when constructing the Hashmap instance

Details

The following atomic vector types are currently supported for keys:

The following atomic vector types are currently supported for values:

Value

a Hashmap object

See Also

Hashmap-class for a more detailed discussion of available methods

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
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)

hashmap documentation built on May 1, 2019, 10:13 p.m.