Debian Codegraph @

R/map.R

raw
1 Map <- R6Class(
2 'Map',
3 portable = FALSE,
4 public = list(
5 initialize = function() {
6 private$map <<- fastmap()
7 },
8 get = function(key) {
9 map$get(key)
10 },
11 set = function(key, value) {
12 map$set(key, value)
13 value
14 },
15 mget = function(keys) {
16 map$mget(keys)
17 },
18 mset = function(...) {
19 map$mset(...)
20 },
21 remove = function(key) {
22 if (!map$has(key))
23 return(NULL)
24
25 result <- map$get(key)
26 map$remove(key)
27 result
28 },
29 containsKey = function(key) {
30 map$has(key)
31 },
32 keys = function(sort = FALSE) {
33 map$keys(sort = sort)
34 },
35 values = function(sort = FALSE) {
36 map$as_list(sort = sort)
37 },
38 clear = function() {
39 map$reset()
40 },
41 size = function() {
42 map$size()
43 }
44 ),
45
46 private = list(
47 map = NULL
48 )
49 )
50
51 #' @export
52 as.list.Map <- function(x, ...) {
53 x$values()
54 }
55
56 #' @export
57 length.Map <- function(x) {
58 x$size()
59 }