HashMap | R Documentation |
R lists with named elements are not hashed. Hash lookups are O(1), because during insert the key is converted to an integer using a hash function, and then the value put in the space hash(key) (this is a big simplification and avoids the complexity of dealing with collisions). Lookups of the key just require hashing the key to find the value's position (which is O(1), versus a O(n) array lookup). R lists use name lookups which are O(n).
HashMap
R6Class
object.
Object of R6Class
with methods for key-value mapping
field(s)
access all via ()
“' HashMap$new() “'
For full documentation of each method go to https://github.com/ChrisNice89/ORM
new()
This method creates a HashMap instance
.
put(key = "", value = NA)
store key-value pair(s)
get(key,unname=TRUE)
access item(s) with associated key(s)
hm<-HashMap$new() keys<- c("tic", "tac", "toe") values <- c(1, 22, 333) hm$put("key",1) hm$put(key = keys,value = values) hm$get(keys) hm$get("tic") hm$size() hm hm$remove("tic") hm$get("tic") hm$size() hm$getKeys()[1] hm$getValues()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.