fastmap2 | R Documentation |
fastmap::fastmap
fastmap
provides a key-value store where the keys are strings and the
values are any R objects. It differs from normal environment that
fastmap
avoids memory leak. fastmap2
is a wrapper for fastmap
, which provides several generic
functions such that it has similar behaviors to lists or
environments
fastmap2(missing_default = NULL)
## S3 method for class 'fastmap2'
x[[name]]
## S3 method for class 'fastmap2'
x$name
## S3 replacement method for class 'fastmap2'
x[[name]] <- value
## S3 replacement method for class 'fastmap2'
x$name <- value
## S3 method for class 'fastmap2'
x[i, j = NULL, ...]
## S3 replacement method for class 'fastmap2'
x[i, j = NULL, ...] <- value
## S3 method for class 'fastmap2'
names(x)
## S3 method for class 'fastmap2'
print(x, ...)
## S3 method for class 'fastmap2'
length(x)
## S3 method for class 'fastmap2'
as.list(x, recursive = FALSE, sorted = FALSE, ...)
missing_default |
passed to |
x |
a |
name |
name, or key of the value |
value |
any R object |
i , j |
vector of names |
... |
passed to other methods |
recursive |
whether to recursively apply |
sorted |
whether to sort names; default is false |
A list of 'fastmap2'
instance
## --------------------------- 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.