## --------------------------- Basic Usage --------------------------
map <- fastmap2()
map$a = 1
map$b = 2
print(map)
map[c('a', 'b')]
# Alternative way
map['a', 'b']
map[c('c', 'd')] <- 3:4
# or
map['e', 'f'] <- 5:6
# The order is not guaranteed, unless sort=TRUE
as.list(map)
as.list(map, sort=TRUE)
names(map)
length(map)
## ----------------------- NULL value handles -----------------------
map$b <- NULL
names(map) # 'b' still exists!
as.list(map) # 'b' is NULL, but still there
# to remove 'b', you have to use `@remove` method
map$`@remove`('b')
## ---------------- Native fastmap::fastmap methods -----------------
# whether map has 'a'
map$`@has`('a')
# Remove a name from list
map$`@remove`('a')
# remove all from list
map$`@reset`()
print(map)
Run the code above in your browser using DataLab