R: Atomic vector hash map

hashmap {hashmap} | R Documentation

## Atomic vector hash map

### Description

Create a new `Hashmap` instance

### Usage

    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

    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)

[Package hashmap version 0.2.2 Index]