intmap

R-CMD-check R-CMD-check-valgrind

Ordered containers with integer keys.


imap <- intmap$new(
  keys = c(11, -2), values = list(c("a", "b"), list(333, 4444, 55555))
)
imap
## `intmap` object containing 2 items:
## 
##   "-2" -> list: 333, 4444, 55555
##   "11" -> character vector: a, b
imap$size()
## [1] 2
imap$keys()
## [1] -2 11
imap$values()
## [[1]]
## [[1]][[1]]
## [1] 333
## 
## [[1]][[2]]
## [1] 4444
## 
## [[1]][[3]]
## [1] 55555
## 
## 
## [[2]]
## [1] "a" "b"
imap$at(5)
## Nothing
imap$at(11)
## Just
## [1] "a" "b"
from_just(imap$at(11))
## [1] "a" "b"
imap$get(5, default = "I am missing.")
## [1] "I am missing."
imap$get(-2)
## [[1]]
## [1] 333
## 
## [[2]]
## [1] 4444
## 
## [[3]]
## [1] 55555
imap$insert(5, "I am not missing.")
## [1] TRUE
imap
## `intmap` object containing 3 items:
## 
##   "-2" -> list: 333, 4444, 55555
##   "5" -> character: I am not missing.
##   "11" -> character vector: a, b
imap$extract(c(5, 11, 99999))
## `intmap` object containing 2 items:
## 
##   "5" -> character: I am not missing.
##   "11" -> character vector: a, b
imap2 <- intmap$new(
  c(-2, 0, 1),
  list("I will be ignored", iris, mtcars)
)
imap$merge(imap2)
imap
## `intmap` object containing 5 items:
## 
##   "-2" -> list: 333, 4444, 55555
##   "0" -> data.frame
##   "1" -> data.frame
##   "5" -> character: I am not missing.
##   "11" -> character vector: a, b