The hashtable packages provides three implementations of hash tables and hash maps:
- using
std::unordered_mapandstd::unordered_setfrom C++, in functionshash_table()andhash_set(), - using the fastmatch package, in functions
hash_fm_table()andhash_fm_set(), - using environment, in functions
hash_env_table()andhash_env_set().
They share the same user interface.
Install
library(devtools)
install_github("jokergoo/hashtable")Usage
Hash table
library(hashtable)
h1 = hash_table(letters, 1:26)
h2 = hash_fm_table(letters, 1:26)
h3 = hash_env_table(letters, 1:26)
h1
## A hash table [hash_unordered_map] with 26 key-value (integer) pairs
## v => 22
## u => 21
## z => 26
## ......
## b => 2
## w => 23
## a => 1
Hash set
h1 = hash_set(letters)
h2 = hash_fm_set(letters)
h3 = hash_env_set(letters)
h1
## A hash set [hash_unordered_set] with 26 keys (character)
Benchmark
See https://jokergoo.github.io/hashtable/articles/benchmark.html.