Atomic vector hash map

Share:

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:

  • integer

  • numeric

  • character

  • Date

  • POSIXct

The following atomic vector types are currently supported for values:

  • logical

  • integer

  • numeric

  • character

  • complex

  • Date

  • POSIXct

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)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.