This code is based on:

#-- Define functions on Hash Tuples (Python alike) ---------------------
# functions: new/def, len, set/get, has_key, keys, items, values, del, clear
def.h <- function() new.env( hash=TRUE, parent=emptyenv() )

len.h <- function(dict) length(ls(envir=dict))

set.h <- function(key, val, dict) assign(key, val, envir=dict)

get.h <- function(key, dict, default=NULL) {
    if (exists(key, envir=dict)) { get(key, dict)
    } else { default } 
}

has_key <- function(key, dict) exists(key, envir=dict)

keys.h <- function(dict) ls(envir=dict)

items.h <- function(dict) as.list(dict)

values.h <- function(dict, mode='character') {
    l <- as.list(dict)
    n <- length(l)
    if (n==0) invisible(NULL)
    v <- vector('character', n)
    for (i in 1:n) v[i] <- l[[i]]
    if (mode=='numeric') v <- as.numeric(v)
    return(v)
}

del.h <- function(key, dict) {
    if (exists(key, envir=dict)) {
        val <- get.h(key, dict)
        rm(list=c(key), envir=dict)
    } else {
        val <- NULL
    }
    invisible(val)
}

clear.h <- function(dict) {
    rm(list=keys.h(dict), envir=dict)
}

