MyNixOS website logo
Description

Ordered Containers with Integer Keys.

Provides a key-value store data structure. The keys are integers and the values can be any R object. This is like a list but indexed by a set of integers, not necessarily contiguous and possibly negative. The implementation uses a 'R6' class. These containers are not faster than lists but their usage can be more convenient for certain situations.

intmap

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

Ordered containers with integer keys.


  • Create a new integer map.
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
  • How many entries are there in the map?
imap$size()
## [1] 2
  • Get the keys (always ordered) and the values.
imap$keys()
## [1] -2 11
imap$values()
## [[1]]
## [[1]][[1]]
## [1] 333
## 
## [[1]][[2]]
## [1] 4444
## 
## [[1]][[3]]
## [1] 55555
## 
## 
## [[2]]
## [1] "a" "b"
  • Get the item of a given key.
imap$at(5)
## Nothing
imap$at(11)
## Just
## [1] "a" "b"
from_just(imap$at(11))
## [1] "a" "b"
  • Or use the get method with a default value.
imap$get(5, default = "I am missing.")
## [1] "I am missing."
imap$get(-2)
## [[1]]
## [1] 333
## 
## [[2]]
## [1] 4444
## 
## [[3]]
## [1] 55555
  • Insert a new entry.
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
  • Get a submap.
imap$extract(c(5, 11, 99999))
## `intmap` object containing 2 items:
## 
##   "5" -> character: I am not missing.
##   "11" -> character vector: a, b
  • Merge with another map.
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
Metadata

Version

1.0.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows